-
Notifications
You must be signed in to change notification settings - Fork 0
578 lines (512 loc) · 19 KB
/
build.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: build
on:
workflow_dispatch:
push:
# branches: [ main ]
pull_request:
branches: [ main ]
jobs:
semver:
runs-on: ubuntu-latest
outputs:
GITVERSION_SEMVER: ${{ steps.gitversion.outputs.SemVer }}
GITVERSION_ASSEMBLYSEMVER: "${{ steps.gitversion.outputs.AssemblySemVer }}"
GITVERSION_MAJORMINORPATCH: "${{ steps.gitversion.outputs.MajorMinorPatch }}"
GITVERSION_MAJOR: ${{ steps.gitversion.outputs.GITVERSION_MAJOR }}
GITVERSION_MINOR: ${{ steps.gitversion.outputs.GITVERSION_MINOR }}
GITVERSION_PATCH: ${{ steps.gitversion.outputs.GITVERSION_PATCH }}
MACOS_MAJORMINORPATCH: ${{ steps.output1.outputs.MACOS_MAJORMINORPATCH }}
DEBIAN_PKGVERSION: ${{ steps.output1.outputs.DEBIAN_PKGVERSION }}
FLAVOR: ${{ steps.output1.outputs.FLAVOR }}
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
- id: output1
run: |
set -x
printenv | grep GitVersion_ | sort
echo "GITVERSION_SEMVER=${GitVersion_SemVer}" >> "$GITHUB_OUTPUT"
echo "GITVERSION_ASSEMBLYSEMVER=${GitVersion_AssemblySemVer}" >> "$GITHUB_OUTPUT"
echo "GITVERSION_MAJORMINORPATCH=${GitVersion_MajorMinorPatch}" >> "$GITHUB_OUTPUT"
echo "GITVERSION_MAJOR=${GitVersion_Major}" >> "$GITHUB_OUTPUT"
echo "GITVERSION_MINOR=${GitVersion_Minor}" >> "$GITHUB_OUTPUT"
echo "GITVERSION_PATCH=${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
echo "DEBIAN_PKGVERSION=${GitVersion_Major}.${GitVersion_Minor}-${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
if [ "${GitVersion_Major}" == "0" ]
then
echo "MACOS_MAJORMINORPATCH=1.${GitVersion_Minor}.${GitVersion_Patch}" >> "$GITHUB_OUTPUT"
else
echo "MACOS_MAJORMINORPATCH=${GitVersion_MajorMinorPatch}" >> "$GITHUB_OUTPUT"
fi
if [ "$GITHUB_REF_NAME" != "master" ]
then
echo "FLAVOR=_${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
build:
needs: [semver]
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
- name: Build with Maven
run: |
mvn versions:set "-DnewVersion=${{ needs.semver.outputs.GITVERSION_SEMVER }}"
mvn -B package -e --file pom.xml
# - name: Check status
# run: |
# set
# echo -n "Current directory: "
# pwd
# find
- uses: actions/upload-artifact@v4
with:
name: OoliteStarter-generic
path: target/OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-generic.*
package-linux:
needs: [semver,build]
runs-on: ubuntu-latest
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
path: oolitestarter
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: OoliteStarter-generic
path: artifacts
- name: Check status 0
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Extract project
run: |
tar xvfz artifacts/OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-generic.tar.gz
- name: Check status 1
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Prepare AppImage for Ubuntu
run: |
jpackage \
--type app-image \
--app-version "${{ needs.semver.outputs.DEBIAN_PKGVERSION }}" \
--copyright Copyright \
--description "OoliteStarter ${{ needs.semver.outputs.GITVERSION_SEMVER }}" \
--name "OoliteStarter${{ needs.semver.outputs.FLAVOR }}" \
--dest target/appimage \
--temp target/oolite-starter-tmp \
--vendor "OoliteProject" \
--verbose \
--icon oolitestarter/src/main/resources/images/Mr_Gimlet_transparent.png \
--input OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}/dist \
--main-jar OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}.jar \
--main-class oolite.starter.MainFrame \
--resource-dir oolitestarter/src/jpackage/resources-linux \
# --java-options '-splash:$APPDIR/splash.png' \
- name: Tweak AppImage
run: |
cp -v "oolitestarter/src/jpackage/resources-linux/OoliteStarter.desktop" "target/appimage/OoliteStarter${{ needs.semver.outputs.FLAVOR }}/lib/oolitestarter-OoliteStarter.desktop"
# cp -v "oolitestarter/src/main/resources/images/OoliteStarter_Splashscreen_640x360.png" "target/appimage/OoliteStarter/lib/app/splash.png"
- name: Check status 2
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Finish AppImage for Ubuntu
run: |
jpackage \
--verbose \
--app-image target/appimage/OoliteStarter${{ needs.semver.outputs.FLAVOR }} \
--name "OoliteStarter${{ needs.semver.outputs.FLAVOR }}" \
--app-version "${{ needs.semver.outputs.DEBIAN_PKGVERSION }}" \
--dest target \
--license-file oolitestarter/LICENSE \
--icon oolitestarter/src/main/resources/images/Mr_Gimlet_transparent.png \
--resource-dir oolitestarter/src/jpackage/resources-linux
#--linux-shortcut \
#--linux-menu-group Game \
#--linux-app-category misc \
- name: Check status 3
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- uses: actions/upload-artifact@v4
with:
name: OoliteStarter-Ubuntu
path: ./target/oolitestarter*.deb
package-windows:
needs: [semver,build]
runs-on: windows-latest
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
path: oolitestarter
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: OoliteStarter-generic
path: artifacts
- name: Check status 0
run: |
gci env:* | sort-object name
get-childitem . -Recurse | where {!$_.PSIsContainer} | select-object FullName
- name: Extract project
run: |
unzip artifacts\OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-generic.zip
- name: Check status 1
run: |
get-childitem . -Recurse | where {!$_.PSIsContainer} | select-object FullName
- name: Prepare AppImage for Windows
run: |
jpackage --type app-image `
--app-version "${{ needs.semver.outputs.GITVERSION_ASSEMBLYSEMVER }}" `
--copyright Copyright `
--description "OoliteStarter ${{ needs.semver.outputs.GITVERSION_SEMVER }}" `
--name "OoliteStarter${{ needs.semver.outputs.FLAVOR }}" `
--dest target/appimage `
--temp target/oolite-starter-tmp `
--vendor "OoliteProject" `
--verbose `
--icon oolitestarter/src/main/resources/images/Mr_Gimlet_transparent.ico `
--input OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}/dist `
--main-jar OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}.jar `
--main-class oolite.starter.MainFrame
# --resource-dir src/jpackage/resources
- name: Check status 2
run: |
get-childitem . -Recurse | where {!$_.PSIsContainer} | select-object FullName
# for upgrades, it seems we need a UUID - see https://stackoverflow.com/a/67442754/4222206
- name: Finish AppImage for Windows
run: |
jpackage `
--verbose `
--app-image target/appimage/OoliteStarter${{ needs.semver.outputs.FLAVOR }} `
--app-version "${{ needs.semver.outputs.GITVERSION_ASSEMBLYSEMVER }}" `
--name "OoliteStarter${{ needs.semver.outputs.FLAVOR }}" `
--dest target `
--win-shortcut `
--icon oolitestarter/src/main/resources/images/Mr_Gimlet_transparent.ico `
--win-shortcut --win-menu --win-menu-group Oolite `
--win-dir-chooser --win-upgrade-uuid 0a18c6bc-0418-47dc-9526-3a48030f6af6
#--resource-dir src/jpackage/resources
- name: Check status 3
run: |
get-childitem . -Recurse | where {!$_.PSIsContainer} | select-object FullName
- name: Rename result (target\OoliteStarter-0.1.16.0.exe)
run: |
gci env:* | sort-object name
$SRC = "target\OoliteStarter${{ needs.semver.outputs.FLAVOR }}-${{ needs.semver.outputs.GITVERSION_ASSEMBLYSEMVER }}.exe"
$DST = "OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-Windows-$PROCESSOR_ARCHITECTURE.exe"
ren $SRC $DST
with:
PROCESSOR_ARCHITECTURE: ${PROCESSOR_ARCHITECTURE}
- name: Check status 4
run: |
get-childitem . -Recurse | where {!$_.PSIsContainer} | select-object FullName
- uses: actions/upload-artifact@v4
with:
name: OoliteStarter-Windows
path: ./target/*.exe
package-macos:
needs: [semver,build]
runs-on: macos-latest
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
path: oolitestarter
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: OoliteStarter-generic
path: artifacts
- name: Check status 1
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Extract project
run: |
tar xvfz artifacts/OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-generic.tar.gz
- name: Check status 1
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Prepare AppImage for MacOS
run: |
jpackage \
--type app-image \
--app-version "${{ needs.semver.outputs.MACOS_MAJORMINORPATCH }}" \
--copyright Copyright \
--description "OoliteStarter ${{ needs.semver.outputs.GITVERSION_SEMVER }}" \
--name "OoliteStarter" --dest target/appimage \
--temp target/oolite-starter-tmp --vendor "OoliteProject" --verbose \
--icon oolitestarter/src/main/resources/oolite_logo.png \
--input OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}/dist \
--main-jar OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}.jar \
--main-class oolite.starter.MainFrame --mac-package-name "OoliteStarter" \
--resource-dir oolitestarter/src/jpackage/resources-mac \
--vendor OoliteProject
# --java-options '-splash:$APPDIR/splash.png' \
# --mac-sign --mac-package-signing-prefix space.oolite.oolitestarter. \
# --mac-signing-key-user-name "oocube"
# --app-version "${{ needs.semver.outputs.GITVERSION_MAJORMINORPATCH }}" \
#- name: Tweak AppImage
# run: |
# cp -v "oolitestarter/src/main/resources/images/OoliteStarter_Splashscreen_640x360.png" "target/appimage/OoliteStarter.app/Contents/app/splash.png"
- name: Check status 2
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Finish AppImage for MacOS
run: |
jpackage \
--type pkg \
--verbose \
--app-version "${{ needs.semver.outputs.MACOS_MAJORMINORPATCH }}" \
--app-image target/appimage/OoliteStarter.app \
--name "OoliteStarter" \
--icon oolitestarter/src/main/resources/oolite_logo.png \
--dest target \
--resource-dir oolitestarter/src/jpackage/resources-mac \
--vendor OoliteProject
- name: Create ZIP distribution
run: |
cd target/appimage
zip -r ../OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-MacOS-${HOSTTYPE}.zip *
- name: Check status 3
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Rename result
run: |
mv ./target/OoliteStarter-${{ needs.semver.outputs.MACOS_MAJORMINORPATCH }}.pkg ./target/OoliteStarter-${{ needs.semver.outputs.GITVERSION_SEMVER }}-MacOS-${HOSTTYPE}.pkg
- name: Check status 4
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- uses: actions/upload-artifact@v4
with:
name: OoliteStarter-MacOS
path: target/OoliteStarter*
# snap:
# needs: [semver,package-linux]
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout project
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# path: oolitestarter
#
# - name: Download artifacts
# uses: actions/download-artifact@v4
# with:
# name: OoliteStarter-Ubuntu
# path: oolitestarter
#
# - name: Check status 1
# run: |
# printenv | sort
# echo -n "Current directory: "
# pwd
# find . -not -path "./oolitestarter/.git/*"
# env:
# DEBIAN_PKGVERSION: ${{ needs.semver.outputs.DEBIAN_PKGVERSION }}
# GITVERSION_SEMVER: ${{ needs.semver.outputs.GITVERSION_SEMVER }}
#
# - name: version bump snapcraft.yaml
# run: |
# sed -i "s/^version:.*/version: ${{ needs.semver.outputs.GITVERSION_SEMVER }}/g" oolitestarter/snapcraft.yaml
# sed -i "s/^ source:.*/ source: oolitestarter_${{ needs.semver.outputs.DEBIAN_PKGVERSION }}-1_amd64.deb/g" oolitestarter/snapcraft.yaml
# cat oolitestarter/snapcraft.yaml
#
# - name: Build the snap
# id: buildsnap
# uses: snapcore/action-build@v1
# with:
# path: oolitestarter
#
# - name: Check status 2
# run: |
# printenv | sort
# echo -n "Current directory: "
# echo "Snap build output is ${{ steps.buildsnap.outputs.snap }}"
# pwd
# find . -not -path "./oolitestarter/.git/*"
# env:
# DEBIAN_PKGVERSION: ${{ needs.semver.outputs.DEBIAN_PKGVERSION }}
# GITVERSION_SEMVER: ${{ needs.semver.outputs.GITVERSION_SEMVER }}
#
# - name: Publish the snap
# uses: snapcore/action-publish@v1
# env:
# SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPSTORE_LOGIN }}
# with:
# snap: ${{ steps.buildsnap.outputs.snap }}
# release: edge
release:
needs: [semver,package-linux,package-windows,package-macos]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Check status
run: |
set
echo -n "Current directory: "
pwd
find . -not -path "./oolitestarter/.git/*"
- name: Remove old prereleases
if: github.ref != 'refs/heads/master'
uses: dev-drprasad/[email protected]
with:
#repo: <owner>/<repoName> # defaults to current repo
keep_latest: 6
delete_tag_pattern: v\d+\.\d+\.\d+-.*
delete_prerelease_only: 'true'
#delete_branch: '${{ github.ref_name }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Prerelease
if: github.ref != 'refs/heads/master'
id: create_prerelease
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
prerelease: true
title: "OoliteStarter v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
files: |
artifacts/OoliteStarter-generic/*.zip
artifacts/OoliteStarter-generic/*.tar.gz
artifacts/OoliteStarter-Ubuntu/*.deb
artifacts/OoliteStarter-Windows/*.exe
artifacts/OoliteStarter-MacOS/OoliteStarter-*
- name: Remove old releases
if: github.ref == 'refs/heads/master'
uses: dev-drprasad/[email protected]
with:
#repo: <owner>/<repoName> # defaults to current repo
keep_latest: 4
delete_tag_pattern: v\d+\.\d+\.\d+
delete_prerelease_only: 'false'
#delete_branch: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: github.ref == 'refs/heads/master'
id: create_release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
prerelease: false
title: "OoliteStarter v${{ needs.semver.outputs.GITVERSION_SEMVER }}"
files: |
artifacts/OoliteStarter-generic/*.zip
artifacts/OoliteStarter-generic/*.tar.gz
artifacts/OoliteStarter-Ubuntu/*.deb
artifacts/OoliteStarter-Windows/*.exe
artifacts/OoliteStarter-MacOS/OoliteStarter-*
# No longer required as we do not provide a dmg
#
# testdmg:
# needs: [package-macos]
# runs-on: macos-latest
#
# steps:
# - name: Download artifacts
# uses: actions/download-artifact@v4
# with:
# name: OoliteStarter-MacOS
# path: artifacts
#
# - name: Check status
# run: |
# set
# echo -n "Current directory: "
# pwd
# find . -not -path "./oolitestarter/.git/*"
#
# # inspired from https://macwrench.miraheze.org/wiki/Hdiutil
# # and https://stackoverflow.com/questions/18017687/how-to-check-whether-an-app-or-dmg-is-signed-or-not
# - name: Verify/Install
# run: |
# set -x
# F=$(ls artifacts/*.dmg)
#
# echo "Help..."
# hdiutil verify -help
# hdiutil imageinfo -help
# hdiutil hfsanalyze -help
# hdiutil checksum -help
# hdiutil info -help
# hdiutil pmap -help
# codesign -help
#
# echo "Verifying..."
# hdiutil verify -verbose "$F"
# hdiutil imageinfo -verbose "$F"
# hdiutil hfsanalyze -verbose "$F"
# hdiutil checksum -type SHA256 -verbose "$F"
# hdiutil info -verbose
# hdiutil pmap -verbose "$F"
# codesign --verify --verbose "$F"