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

Last change on this file since 19141 was 19072, checked in by taylor.smock, 7 months ago

Fix macOS output names for GitHub Actions

File size: 12.9 KB
Line 
1name: Java CI Build
2env:
3 JAVAFX_VERSION: '17.0.7'
4on:
5 push:
6 branches: [master]
7
8defaults:
9 run:
10 shell: bash
11
12jobs:
13
14 createrelease:
15 name: Create Release
16 runs-on: ubuntu-latest
17 permissions:
18 contents: write # Needed to create actual release
19 env:
20 LANG: en_US.UTF-8
21 outputs:
22 upload_url: ${{ steps.create_release.outputs.upload_url }}
23 josm_revision: ${{ steps.create_revision.outputs.josm_revision }}
24 josm_prerelease: ${{ steps.create_revision.outputs.josm_prerelease }}
25 josm_release_tag: ${{ steps.create_revision.outputs.josm_release_tag }}
26 steps:
27 - name: Checkout
28 uses: actions/checkout@v4
29 with:
30 fetch-depth: 256
31
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 "josm_prerelease=false" >> $GITHUB_OUTPUT
40 josm_release_tag=$josm_revision-tested
41 else
42 echo "josm_prerelease=true" >> $GITHUB_ENV
43 echo "josm_prerelease=true" >> $GITHUB_OUTPUT
44 josm_release_tag=$josm_revision
45 fi
46 echo "josm_revision=$josm_revision" >> $GITHUB_ENV
47 echo "josm_revision=$josm_revision" >> $GITHUB_OUTPUT
48 echo "josm_release_tag=$josm_release_tag" >> $GITHUB_ENV
49 echo "josm_release_tag=$josm_release_tag" >> $GITHUB_OUTPUT
50
51 - name: Create release
52 id: create_release
53 uses: softprops/action-gh-release@v2
54 with:
55 tag_name: ${{ env.josm_release_tag }}
56 name: JOSM release ${{ env.josm_release_tag }}
57 body: |
58 JOSM release ${{ env.josm_release_tag }}
59 draft: false
60 prerelease: ${{ env.josm_prerelease }}
61
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: [11, 17, 21, 22]
72 os: [ubuntu-latest, macos-14, windows-latest]
73 name: Java ${{ matrix.java }} on ${{ matrix.os }}
74 steps:
75 - name: Checkout
76 uses: actions/checkout@v4
77 with:
78 fetch-depth: 256
79
80 - name: Cache
81 uses: actions/cache@v4
82 with:
83 path: |
84 ~/.ivy2/cache/
85 ~/work/josm/josm/tools/
86 key: ${{ runner.os }}-ivy2-${{ hashFiles('build.xml', 'ivy.xml', 'tools/ivy.xml') }}
87
88 - name: Setup Java ${{ matrix.java }}
89 uses: actions/setup-java@v4
90 with:
91 distribution: 'zulu'
92 java-version: ${{ matrix.java }}
93
94 - name: Setup x64 Java (Mac) ${{ matrix.java }}
95 if: ${{ runner.os == 'macos' && runner.arch == 'ARM64' && always() }}
96 uses: actions/setup-java@v4
97 with:
98 distribution: 'zulu'
99 java-version: ${{ matrix.java }}
100 architecture: x64
101
102 - name: Install Ant
103 uses: JOSM/JOSMPluginAction/actions/setup-ant@v2
104
105 - name: Optimise images
106 if: ${{ runner.os == 'macos' && always() }}
107 run: |
108 brew install --cask imageoptim
109 defaults write net.pornel.ImageOptim SvgoEnabled 1
110 defaults write net.pornel.ImageOptim PngCrush2Enabled 1
111 defaults write net.pornel.ImageOptim PngOutEnabled 1
112 /Applications/ImageOptim.app/Contents/MacOS/ImageOptim resources/images
113
114 - name: Build with Ant
115 env:
116 SIGN_ALIAS: ${{ secrets.SIGN_ALIAS }}
117 SIGN_CERT: ${{ secrets.SIGN_CERT }}
118 SIGN_KEYPASS: ${{ secrets.SIGN_KEYPASS }}
119 SIGN_STOREPASS: ${{ secrets.SIGN_STOREPASS }}
120 SIGN_TSA: ${{ secrets.SIGN_TSA }}
121 # Calls ant with -Dreleasebuild=true if we're a 'tested' build
122 run: |
123 if [ ! -z "${SIGN_CERT}" ]; then
124 export SIGN_KEYSTORE=certificate.p12
125 echo "$SIGN_CERT" | base64 --decode > $SIGN_KEYSTORE
126 fi
127 if [ "${{ needs.createrelease.outputs.josm_prerelease }}" == "true" ]; then
128 ANT="ant"
129 else
130 ANT="ant -Dreleasebuild=true"
131 fi
132 $ANT dist
133 if [ ! -z "${SIGN_KEYSTORE}" ]; then rm $SIGN_KEYSTORE; fi
134
135 - name: Upload jar
136 if: ${{ always() && needs.createrelease.outputs.upload_url }}
137 env:
138 ASSET: dist/josm-custom.jar
139 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.jar
140 CONTENT_TYPE: application/java-archive
141 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142 # Use `gh api` instead of `gh release upload` so we can set the content type -- it also lets us avoid renaming files
143 run: |
144 gh api --verbose --method POST \
145 --header "Accept: application/vnd.github+json" \
146 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
147 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
148 --header "X-GitHub-Api-Version: 2022-11-28" \
149 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
150 --input "${{ env.ASSET }}"
151
152 - name: Build and package for macOS
153 if: ${{ runner.os == 'macos' && matrix.java != '11' && always() }}
154 env:
155 CERT_MACOS_P12: ${{ secrets.CERT_MACOS_P12 }}
156 CERT_MACOS_PW: ${{ secrets.CERT_MACOS_PW }}
157 APPLE_ID: ${{ secrets.APPLE_ID }}
158 APPLE_ID_PW: ${{ secrets.APPLE_ID_PW }}
159 APPLE_ID_TEAM: ${{ secrets.APPLE_ID_TEAM }}
160 run: |
161 function setup_openjfx() {
162 if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip ]; then
163 curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_osx-${1}_bin-jmods.zip
164 fi
165 unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}_${2}-jmods.zip
166 mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
167 }
168
169 if [ ${{ runner.arch }} == "ARM64" ]; then
170 JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_ARM64}" PATH="${JAVA_HOME_${{ matrix.java }}_ARM64}/bin:${PATH}" setup_openjfx aarch64 ARM64
171 JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_X64}" PATH="${JAVA_HOME_${{ matrix.java }}_X64}/bin:${PATH}" setup_openjfx x64 X64
172 JAVA_HOME="${JAVA_HOME_${{ matrix.java }}_ARM64}" ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }} "${JAVA_HOME_${{ matrix.java }}_X64}"
173 else
174 setup_openjfx x64 X64
175 ./native/macosx/macos-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
176 fi
177
178 - name: Setup Windows PATH
179 if: ${{ runner.os == 'windows' && matrix.java != '11' && always() }}
180 run: |
181 echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH
182 echo "C:\Program Files (x86)\Windows Kits\10\bin\x64" >> $GITHUB_PATH
183 echo "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" >> $GITHUB_PATH
184
185 - name: Build and package for Windows
186 if: ${{ runner.os == 'windows' && matrix.java != '11' && always() }}
187 env:
188 SIGN_CERT: ${{ secrets.SIGN_CERT }}
189 SIGN_STOREPASS: ${{ secrets.SIGN_STOREPASS }}
190 SIGN_TSA: ${{ secrets.SIGN_TSA }}
191 run: |
192 if [ ! -f tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip ]; then
193 curl -o tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip https://download2.gluonhq.com/openjfx/${JAVAFX_VERSION}/openjfx-${JAVAFX_VERSION}_windows-x64_bin-jmods.zip
194 fi
195 unzip tools/openjfx-${JAVAFX_VERSION}_${{ runner.os }}-jmods.zip
196 mv javafx-jmods-${JAVAFX_VERSION}/*.jmod $JAVA_HOME/jmods/
197 ./native/windows/win-jpackage.sh ${{ needs.createrelease.outputs.josm_revision }}
198
199 - name: Upload macOS app
200 if: ${{ runner.os == 'macos' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
201 env:
202 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
203 CONTENT_TYPE: application/zip
204 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.zip
205 run: |
206 curl --location \
207 --request POST \
208 --header "Accept: application/vnd.github+json" \
209 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
210 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
211 --header "X-GitHub-Api-Version: 2022-11-28" \
212 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
213 --data-binary "@app/JOSM.zip"
214
215 - name: Upload macOS app (x64)
216 if: ${{ runner.os == 'macos' && matrix.java != '11' && always() && runner.arch == 'ARM64' && needs.createrelease.outputs.upload_url }}
217 env:
218 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}-x64.zip
219 CONTENT_TYPE: application/zip
220 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221 # Use `curl` instead of `gh release upload` so we can set the content type
222 run: |
223 curl --location \
224 --request POST \
225 --header "Accept: application/vnd.github+json" \
226 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
227 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
228 --header "X-GitHub-Api-Version: 2022-11-28" \
229 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
230 --data-binary "@app/JOSM_${{ matrix.java }}_x86_64.zip"
231
232 - name: Upload macOS app (aarch64)
233 if: ${{ runner.os == 'macos' && matrix.java != '11' && always() && runner.arch == 'ARM64' && needs.createrelease.outputs.upload_url }}
234 env:
235 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}-aarch64.zip
236 CONTENT_TYPE: application/zip
237 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
238 # Use `curl` instead of `gh release upload` so we can set the content type
239 run: |
240 curl --location \
241 --request POST \
242 --header "Accept: application/vnd.github+json" \
243 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
244 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
245 --header "X-GitHub-Api-Version: 2022-11-28" \
246 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
247 --data-binary "@app/JOSM_${{ matrix.java }}_arm64.zip"
248
249 - name: Upload Windows Installer executable
250 if: ${{ runner.os == 'windows' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
251 env:
252 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.exe
253 CONTENT_TYPE: application/vnd.microsoft.portable-executable
254 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
255 # Use `curl` instead of `gh release upload` so we can set the content type
256 run: |
257 curl --location \
258 --request POST \
259 --header "Accept: application/vnd.github+json" \
260 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
261 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
262 --header "X-GitHub-Api-Version: 2022-11-28" \
263 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
264 --data-binary "@app/JOSM.exe"
265
266 - name: Upload Windows Installer package
267 if: ${{ runner.os == 'windows' && matrix.java != '11' && always() && needs.createrelease.outputs.upload_url }}
268 env:
269 ASSET_NAME: JOSM-${{ runner.os}}-java${{ matrix.java }}-${{ needs.createrelease.outputs.josm_revision }}.msi
270 CONTENT_TYPE: application/x-ole-storage
271 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272 # Use `curl` instead of `gh release upload` so we can set the content type
273 run: |
274 curl --location \
275 --request POST \
276 --header "Accept: application/vnd.github+json" \
277 --header "Authorization: Bearer ${{ env.GITHUB_TOKEN }}" \
278 --header "Content-Type: ${{ env.CONTENT_TYPE }}" \
279 --header "X-GitHub-Api-Version: 2022-11-28" \
280 "$(sed 's/{?name,label}/?name=${{ env.ASSET_NAME }}/g' <<< ${{ needs.createrelease.outputs.upload_url }})" \
281 --data-binary "@app/JOSM.msi"
Note: See TracBrowser for help on using the repository browser.