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