1 | name: Java CI |
---|
2 | env: |
---|
3 | junit_platform_version: '1.7.0' |
---|
4 | # ANT_HOME is also our ant version |
---|
5 | ANT_HOME: 'apache-ant-1.10.9' |
---|
6 | on: |
---|
7 | push: |
---|
8 | branches: [master] |
---|
9 | pull_request: |
---|
10 | branches: [master] |
---|
11 | |
---|
12 | defaults: |
---|
13 | run: |
---|
14 | shell: bash |
---|
15 | |
---|
16 | jobs: |
---|
17 | createrelease: |
---|
18 | name: Create Release |
---|
19 | runs-on: ubuntu-latest |
---|
20 | env: |
---|
21 | LANG: en_US.UTF-8 |
---|
22 | outputs: |
---|
23 | upload_url: ${{ steps.create_release.outputs.upload_url }} |
---|
24 | josm_revision: ${{ steps.create_revision.outputs.josm_revision }} |
---|
25 | josm_prerelease: ${{ steps.create_revision.outputs.josm_prerelease }} |
---|
26 | josm_release_tag: ${{ steps.create_revision.outputs.josm_release_tag }} |
---|
27 | steps: |
---|
28 | - name: Checkout |
---|
29 | uses: actions/checkout@v2 |
---|
30 | with: |
---|
31 | fetch-depth: 256 |
---|
32 | - name: Set revision env variable |
---|
33 | id: create_revision |
---|
34 | # grab josm revision from last git-svn-id |
---|
35 | run: | |
---|
36 | josm_revision="$(git log -1 --grep 'git-svn-id: https://josm.openstreetmap.de/svn/trunk@' --pretty=format:%B | tail -1 | sed -n 's%git-svn-id: https://josm.openstreetmap.de/svn/trunk@\([0-9]*\) [-0-9a-f]*%\1%p')" |
---|
37 | if [[ "$josm_revision" == "$(curl --silent https://josm.openstreetmap.de/tested)" ]]; then |
---|
38 | echo "josm_prerelease=false" >> $GITHUB_ENV |
---|
39 | echo "::set-output name=josm_prerelease::false" |
---|
40 | josm_release_tag=$josm_revision-tested |
---|
41 | else |
---|
42 | echo "josm_prerelease=true" >> $GITHUB_ENV |
---|
43 | echo "::set-output name=josm_prerelease::true" |
---|
44 | josm_release_tag=$josm_revision |
---|
45 | fi |
---|
46 | echo "josm_revision=$josm_revision" >> $GITHUB_ENV |
---|
47 | echo "::set-output name=josm_revision::$josm_revision" |
---|
48 | echo "josm_release_tag=$josm_release_tag" >> $GITHUB_ENV |
---|
49 | echo "::set-output name=josm_release_tag::$josm_release_tag" |
---|
50 | - name: Create release |
---|
51 | id: create_release |
---|
52 | uses: actions/create-release@v1 |
---|
53 | env: |
---|
54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token |
---|
55 | with: |
---|
56 | tag_name: ${{ env.josm_release_tag }} |
---|
57 | release_name: JOSM.app release ${{ env.josm_release_tag }} |
---|
58 | body: | |
---|
59 | JOSM.app release ${{ env.josm_release_tag }} |
---|
60 | draft: false |
---|
61 | prerelease: ${{ env.josm_prerelease }} |
---|
62 | build: |
---|
63 | needs: createrelease |
---|
64 | runs-on: ${{ matrix.os }} |
---|
65 | env: |
---|
66 | LANG: en_US.UTF-8 |
---|
67 | strategy: |
---|
68 | fail-fast: false |
---|
69 | matrix: |
---|
70 | # test against latest update of each major Java version, as well as specific updates of LTS versions: |
---|
71 | java: [8, 11, 15, 16-ea] |
---|
72 | os: [ubuntu-latest, macos-latest, windows-latest] |
---|
73 | headless: ["true", "false"] |
---|
74 | exclude: |
---|
75 | - java: 8 |
---|
76 | os: macos-latest |
---|
77 | - java: 11 |
---|
78 | os: macos-latest |
---|
79 | - headless: "false" |
---|
80 | os: macos-latest |
---|
81 | - headless: "false" |
---|
82 | os: windows-latest |
---|
83 | name: Java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }} |
---|
84 | steps: |
---|
85 | - name: Checkout |
---|
86 | uses: actions/checkout@v2 |
---|
87 | with: |
---|
88 | fetch-depth: 256 |
---|
89 | - name: Cache |
---|
90 | uses: actions/cache@v2.0.0 |
---|
91 | with: |
---|
92 | path: | |
---|
93 | ~/.ivy2/cache/ |
---|
94 | ~/work/josm/josm/tools/ |
---|
95 | build-tools-cache/ |
---|
96 | key: ${{ runner.os }}-ivy2-${{ hashFiles('ivy.xml') }} |
---|
97 | - name: Setup java |
---|
98 | uses: actions/setup-java@v1.4.3 |
---|
99 | with: |
---|
100 | java-version: ${{ matrix.java }} |
---|
101 | - name: Install ant ${{ env.ANT_HOME }} and junit ${{ env.junit_platform_version }} |
---|
102 | run: | |
---|
103 | mkdir -p build-tools-cache/ |
---|
104 | cd build-tools-cache/ |
---|
105 | if [ ! -f ${{ env.ANT_HOME }}-bin.tar.gz ]; then |
---|
106 | curl -o ${{ env.ANT_HOME }}-bin.tar.gz https://downloads.apache.org/ant/binaries/${{ env.ANT_HOME }}-bin.tar.gz |
---|
107 | fi |
---|
108 | if [ ! -f junit-platform-console-standalone-${{ env.junit_platform_version }}.jar ]; then |
---|
109 | curl -o junit-platform-console-standalone-${{ env.junit_platform_version }}.jar https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${{ env.junit_platform_version }}/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar |
---|
110 | fi |
---|
111 | cd .. |
---|
112 | tar zxf build-tools-cache/${{ env.ANT_HOME }}-bin.tar.gz |
---|
113 | cp build-tools-cache/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar ${{ env.ANT_HOME }}/lib/junit-platform-console-standalone-${{ env.junit_platform_version }}.jar |
---|
114 | - name: Print ant version, expecting ${{ env.ANT_HOME }} |
---|
115 | run: ${{ env.ANT_HOME }}/bin/ant -version |
---|
116 | - name: Optimise images |
---|
117 | if: ${{ runner.os == 'macos' && always() }} |
---|
118 | run: | |
---|
119 | brew install --cask imageoptim |
---|
120 | defaults write net.pornel.ImageOptim SvgoEnabled 1 |
---|
121 | defaults write net.pornel.ImageOptim PngCrush2Enabled 1 |
---|
122 | defaults write net.pornel.ImageOptim PngOutEnabled 1 |
---|
123 | /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images |
---|
124 | - name: Build with Ant |
---|
125 | # Calls ant with -Dreleasebuild=true if we're a 'tested' build |
---|
126 | # Disables errorprone for Java 16 |
---|
127 | # See https://github.com/google/error-prone/issues/1872 |
---|
128 | run: | |
---|
129 | if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then |
---|
130 | ANT="${{ env.ANT_HOME }}/bin/ant" |
---|
131 | else |
---|
132 | ANT="${{ env.ANT_HOME }}/bin/ant -Dreleasebuild=true" |
---|
133 | fi |
---|
134 | if [[ "x${{ matrix.java }}x" =~ x1[6-9](-ea)?x ]]; then |
---|
135 | $ANT -DnoErrorProne dist |
---|
136 | else |
---|
137 | $ANT dist |
---|
138 | fi |
---|
139 | - name: Upload jar |
---|
140 | # Only run on matrix.headless to avoid double jars. They should be the same jars. |
---|
141 | if: ${{ always() && matrix.headless == 'true' }} |
---|
142 | id: upload-jar |
---|
143 | env: |
---|
144 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
---|
145 | uses: actions/upload-release-asset@v1 |
---|
146 | with: |
---|
147 | upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`. |
---|
148 | asset_path: dist/josm-custom.jar |
---|
149 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar |
---|
150 | asset_content_type: application/java-archive |
---|
151 | - name: Test with Ant, headless ${{ matrix.headless }} |
---|
152 | if: ${{ needs.createrelease.outputs.josm_prerelease }} |
---|
153 | run: | |
---|
154 | ANT="${{ env.ANT_HOME }}/bin/ant -DnoJavaFX=true test-unit-hardfail" |
---|
155 | if [ "${{ matrix.headless }}" == "true" ]; then |
---|
156 | $ANT -Dtest.headless=true |
---|
157 | else |
---|
158 | xvfb-run $ANT -Dtest.headless=false |
---|
159 | fi |
---|
160 | - name: Dump errors if failed |
---|
161 | if: ${{ failure() }} |
---|
162 | run: "grep -L ', Failures: 0, Skipped: ' test/report/*.txt | xargs cat" |
---|
163 | - name: Upload Ant reports |
---|
164 | if: ${{ always() }} |
---|
165 | uses: actions/upload-artifact@v2 |
---|
166 | with: |
---|
167 | name: Ant reports for JOSM ${{ needs.createrelease.outputs.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }} |
---|
168 | path: test/report/*.txt |
---|
169 | - name: Publish Test Report with junit-report-annotations-action |
---|
170 | uses: ashley-taylor/junit-report-annotations-action@1.3 |
---|
171 | if: always() |
---|
172 | with: |
---|
173 | access-token: ${{ secrets.GITHUB_TOKEN }} |
---|
174 | path: 'test/report/TEST*.xml' |
---|
175 | - name: Publish Test Report with action-junit-report |
---|
176 | if: always() |
---|
177 | uses: mikepenz/action-junit-report@v1 |
---|
178 | with: |
---|
179 | report_paths: 'test/report/TEST*.xml' |
---|
180 | github_token: ${{ secrets.GITHUB_TOKEN }} |
---|
181 | - name: Build and package for macOS |
---|
182 | if: ${{ runner.os == 'macos' && always() }} |
---|
183 | env: |
---|
184 | CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }} |
---|
185 | CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }} |
---|
186 | APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }} |
---|
187 | run: | |
---|
188 | ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }} |
---|
189 | - name: Upload app |
---|
190 | if: ${{ runner.os == 'macos' && always() }} |
---|
191 | id: upload-app |
---|
192 | uses: actions/upload-release-asset@v1 |
---|
193 | env: |
---|
194 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
---|
195 | with: |
---|
196 | upload_url: ${{ needs.createrelease.outputs.upload_url }} # This pulls from the CREATE RELEASE job above, referencing its ID to get its outputs object, which include a `upload_url`. |
---|
197 | asset_path: app/JOSM.zip |
---|
198 | asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip |
---|
199 | asset_content_type: application/zip |
---|