source: josm/trunk/.github/workflows/ant.yml@ 17487

Last change on this file since 17487 was 17487, checked in by GerdP, 4 years ago

see #20257:macOS build process fixes and improvements

File size: 8.9 KB
Line 
1name: Java CI
2env:
3 junit_platform_version: '1.7.0'
4 # ANT_HOME is also our ant version
5 ANT_HOME: 'apache-ant-1.10.9'
6on:
7 push:
8 branches: [master]
9 pull_request:
10 branches: [master]
11
12defaults:
13 run:
14 shell: bash
15
16jobs:
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 cask install 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: Set Is-Local-Build
125 if: ${{ ! needs.createrelease.outputs.josm_prerelease }}
126 run: |
127 ant create-revision
128 sed -i.bak '/Is-Local-Build/d' resources/REVISION
129 - name: Build with Ant
130 # Disables errorprone for Java 16
131 # See https://github.com/google/error-prone/issues/1872
132 run: |
133 if [[ "x${{ matrix.java }}x" =~ x1[6-9](-ea)?x ]]; then
134 ${{ env.ANT_HOME }}/bin/ant -DnoErrorProne dist
135 else
136 ${{ env.ANT_HOME }}/bin/ant dist
137 fi
138 - name: Upload jar
139 # Only run on matrix.headless to avoid double jars. They should be the same jars.
140 # uses `gh release upload` to avoid https://github.com/actions/upload-release-asset/issues/69
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 # run: |
152 # cp dist/josm-custom.jar JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
153 # gh release upload ${{ needs.createrelease.outputs.josm_release_tag }} JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
154 - name: Test with Ant, headless ${{ matrix.headless }}
155 if: ${{ needs.createrelease.outputs.josm_prerelease }}
156 run: |
157 ANT="${{ env.ANT_HOME }}/bin/ant -DnoJavaFX=true test-unit-hardfail"
158 if [ "${{ matrix.headless }}" == "true" ]; then
159 $ANT -Dtest.headless=true
160 else
161 xvfb-run $ANT -Dtest.headless=false
162 fi
163 - name: Dump errors if failed
164 if: ${{ failure() }}
165 run: "grep -L ', Failures: 0, Skipped: ' test/report/*.txt | xargs cat"
166 - name: Upload Ant reports
167 if: ${{ always() }}
168 uses: actions/upload-artifact@v2
169 with:
170 name: Ant reports for JOSM ${{ needs.createrelease.outputs.josm_revision }} on java ${{ matrix.java }} on ${{ matrix.os }} with headless=${{ matrix.headless }}
171 path: test/report/*.txt
172 - name: Publish Test Report with junit-report-annotations-action
173 uses: ashley-taylor/junit-report-annotations-action@1.3
174 if: always()
175 with:
176 access-token: ${{ secrets.GITHUB_TOKEN }}
177 path: 'test/report/TEST*.xml'
178 - name: Publish Test Report with action-junit-report
179 if: always()
180 uses: mikepenz/action-junit-report@v1
181 with:
182 report_paths: 'test/report/TEST*.xml'
183 github_token: ${{ secrets.GITHUB_TOKEN }}
184 - name: Build and package for macOS
185 if: ${{ runner.os == 'macos' && always() }}
186 env:
187 CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
188 CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
189 APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
190 run: |
191 ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
192 - name: Upload app
193 if: ${{ runner.os == 'macos' && always() }}
194 id: upload-app
195 uses: actions/upload-release-asset@v1
196 env:
197 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
198 with:
199 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`.
200 asset_path: app/JOSM.zip
201 asset_name: JOSM-${{ runner.os}}-java${{ matrix.java }}.zip
202 asset_content_type: application/zip
Note: See TracBrowser for help on using the repository browser.