1+ name : CI
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ pull_request :
8+ branches :
9+ - master
10+
11+ permissions :
12+ checks : write
13+ contents : write
14+ pull-requests : write
15+
16+ jobs :
17+ build :
18+ strategy :
19+ fail-fast : false
20+ matrix :
21+ # Alternative for testing on multiple platforms. Ubuntu runs the quickest with the latest JVM.
22+ # os: [ubuntu-latest, windows-latest, macos-latest]
23+ # java-version: [11, 17]
24+ os : [ ubuntu-latest ]
25+ java-version : [ 17 ]
26+ runs-on : ${{ matrix.os }}
27+ timeout-minutes : 10
28+ steps :
29+ - name : Checkout
30+ uses : actions/checkout@v3
31+ with :
32+ fetch-depth : 0 # Required depth for JReleaser
33+ - name : Setup Java JDK
34+ uses : actions/setup-java@v3
35+ with :
36+ distribution : adopt-hotspot
37+ java-version : ${{ matrix.java-version }}
38+
39+ # Run tests & build artifact
40+ - name : Run tests & build release
41+ run : ./mvnw package
42+
43+ # Upload test results
44+ - name : Upload Test Results
45+ 46+ if : always()
47+ with :
48+ name : Event File
49+ retention-days : 21
50+ path : |
51+ **/TEST-*
52+ **/hs_err_pid*
53+
54+ # Set JReleaser version to the project version: "var_to_set=$(command_to_run)" >> sink
55+ # - For maven: echo "JRELEASER_PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
56+ # - For gradle: echo "JRELEASER_PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version: ).*')" >> $GITHUB_ENV
57+ - name : Extract project version to environment variable
58+ run : echo "JRELEASER_PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
59+
60+ # Check if a tag exists that matches the current project version.
61+ # Write the existence state to the step output 'tagExists'.
62+ - name : ' Check: package version has corrosponding git tag'
63+ id : tagged
64+ shell : bash
65+ run : git show-ref --tags --verify --quiet -- "refs/tags/${{ env.JRELEASER_PROJECT_VERSION }}" && echo "tagExists=1" >> $GITHUB_OUTPUT || echo "tagExists=0" >> $GITHUB_OUTPUT
66+
67+ # Make release with JReleaser, only running when the project version does not exist as a tag on the repository.
68+ - name : Release
69+ if : steps.tagged.outputs.tagExists == 0
70+ uses : jreleaser/release-action@v2
71+ with :
72+ arguments : full-release
73+ env :
74+ JRELEASER_PROJECT_VERSION : ${{ env.JRELEASER_PROJECT_VERSION }}
75+ JRELEASER_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
76+
77+ # Upload JRelease debug log
78+ - name : JReleaser output
79+ if : steps.tagged.outputs.tagExists == 0
80+ uses : actions/upload-artifact@v3
81+ with :
82+ name : jreleaser-release
83+ path : |
84+ out/jreleaser/trace.log
85+ out/jreleaser/output.properties
86+
87+ # Taken from: https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#support-fork-repositories-and-dependabot-branches
88+ # - Required for test-results to be published
89+ event_file :
90+ name : " Event File"
91+ runs-on : ubuntu-latest
92+ steps :
93+ - name : Upload
94+ uses : actions/upload-artifact@v2
95+ with :
96+ name : Event File
97+ path : ${{ github.event_path }}
0 commit comments