-
Notifications
You must be signed in to change notification settings - Fork 5
84 lines (79 loc) · 3.62 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout omero-test-infra
uses: actions/checkout@v3
with:
repository: openmicroscopy/omero-test-infra
submodules: true
path: .omero
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Append 'SNAPSHOT' to version if 'push' happened on 'main'
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
mvn help:evaluate -N -Dexpression=project.version|grep -v '\['
VERSION=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[')
mvn versions:set -DnewVersion=$VERSION-SNAPSHOT
- name: Append branch name to version if 'push' did not happen on 'main' or a tag
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')}}
run: |
mvn help:evaluate -N -Dexpression=project.version|grep -v '\['
VERSION=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[')
mvn versions:set -DnewVersion=$VERSION-${GITHUB_REF##*/}
- name: Test with Maven and omero-test-infra through Docker
run: $GITHUB_WORKSPACE/.omero/lib-docker
env:
DOCKER_ARGS: -v ${{ env.HOME }}/.m2:/root/.m2 -v ${{ github.workspace }}/target:/src/target -t
- name: Set folders ownership back to current user
run: sudo chown -R $(id -u):$(id -g) $GITHUB_WORKSPACE && sudo chown -R $(id -u):$(id -g) $HOME
- name: Upload to codecov after successful tests
if: ${{ success() }}
run: bash <(curl -s https://codecov.io/bash)
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: jars
path: |
target/*.jar
!target/*-with-dependencies.jar
- name: Install gpg secret key
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
run: cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
- name: Publish to GitHub Packages Apache Maven
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }}
run: mvn deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -DskipTests -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}