-
Notifications
You must be signed in to change notification settings - Fork 4
664 lines (552 loc) · 24.5 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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com)
# SPDX-FileContributor: Sebastian Thomschke (Vegard IT GmbH)
# SPDX-License-Identifier: Apache-2.0
# SPDX-ArtifactOfProjectHomePage: https://github.com/vegardit/copycat
#
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Build
on:
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
- '.github/workflows/stale.yml'
pull_request:
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
additional_maven_args:
description: 'Additional Maven Args'
required: false
default: ''
defaults:
run:
shell: bash
env:
JAVA_VERSION: 17
RELEASE_NAME: "latest"
jobs:
###########################################################
maven-build:
###########################################################
runs-on: ubuntu-24.04
steps:
- name: "Show: GitHub context"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo $GITHUB_CONTEXT
- name: "Show: environment variables"
run: env | sort
- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: "Install: JDK ${{ env.JAVA_VERSION }} ☕"
uses: actions/setup-java@v4 # https://github.com/actions/setup-java
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: "Cache: Restore"
id: cache-restore
uses: actions/cache/restore@v4 # https://github.com/actions/cache/blob/main/restore/README.md
with:
# IMPORTANT: path must have exactly the same value as in the cache save step otherwise restore will fail with cache key not found
path: |
~/.m2/bin
~/.m2/repository
!~/.m2/repository/.cache
!~/.m2/repository/.meta
!~/.m2/repository/com/vegardit/maven
!~/.m2/repository/*SNAPSHOT*
key: ${{ runner.os }}-${{ runner.arch }}-mvn-repo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-mvn-repo-
- name: "Move Restored Repo"
if: ${{ steps.cache-restore.outputs.cache-hit }}
run: |
RESTORED_REPO_PATH=$HOME/.m2/repository-restored
mv -v ~/.m2/repository $RESTORED_REPO_PATH
echo "RESTORED_REPO_PATH=$RESTORED_REPO_PATH" >> $GITHUB_ENV
- name: "Test with Maven 🔨"
if: ${{ github.ref_name != 'main' || env.ACT }}
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ github.token }}
MAY_CREATE_RELEASE: false
run: |
bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }}
- name: "Build with Maven 🔨"
if: ${{ github.ref_name == 'main' && !env.ACT }}
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ secrets.GH_API_TOKEN }}
MAY_CREATE_RELEASE: true
run: |
set -eu
# https://github.community/t/github-actions-bot-email-address/17204
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }}
##################################################
# Cache Update
# See https://github.com/actions/cache/issues/342#issuecomment-1399442670
##################################################
- name: "Cache: Delete Previous"
if: ${{ steps.cache-restore.outputs.cache-hit && !env.ACT }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
# "|| true" is to avoid "Error: Resource not accessible by integration" from failing the job
gh actions-cache delete ${{ steps.cache-restore.outputs.cache-primary-key }} --confirm || true
- name: "Cache: Update"
uses: actions/cache/save@v4 # https://github.com/actions/cache/blob/main/save/README.md
with:
path: |
~/.m2/bin
~/.m2/repository
!~/.m2/repository/.cache
!~/.m2/repository/.meta
!~/.m2/repository/com/vegardit/maven
!~/.m2/repository/*SNAPSHOT*
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Test minimized fat jar
run: |
set -ex
mv target/copycat-*-fat-minimized.jar target/copycat-fat.jar
java -jar target/copycat-fat.jar --help
java -jar target/copycat-fat.jar -V
java -jar target/copycat-fat.jar sync target/classes target/classes.copy -v
- name: "Share: maven-build-artifacts"
uses: actions/upload-artifact@v4
with:
name: maven-build-artifacts
path: |
target/copycat-fat.jar
target/picocli-reflections.json
target/bash/bashcompletion.sh
###########################################################
native-image:
###########################################################
runs-on: ${{ matrix.os }}
needs: [maven-build]
strategy:
fail-fast: false
matrix:
# https://github.com/actions/runner-images#available-images
include:
- arch: "linux-amd64"
os: "ubuntu-24.04"
# not using newer graalvm release which produces considerably larger binaries
graal_version: 21.3.3.1 # https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.3.1
graal_install_root: "/opt/graalvm"
- arch: "linux-arm64"
os: "ubuntu-24.04"
# not using newer graalvm release which produces considerably larger binaries
graal_version: 21.3.3.1 # https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.3.1
graal_install_root: "/opt/graalvm"
- arch: "darwin-arm64"
os: "macos-latest" # ARM
# using newer graalvm release because 21.3.3.1 is not available for ARM
graal_version: 23.0.1 # https://github.com/graalvm/graalvm-ce-builds/releases/tag/jdk-23.0.1
graal_install_root: "graalvm"
- arch: "darwin-amd64"
os: "macos-13" # x64
# not using newer graalvm release which produces considerably larger binaries
graal_version: 21.3.3.1 # https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.3.1
graal_install_root: "graalvm"
- arch: "windows-amd64"
os: "windows-latest"
# TODO don't upgrade as newer versions break Windows builds https://github.com/oracle/graal/issues/4340
# not using newer graalvm release which produces considerably larger binaries
graal_version: 21.3.3.1 # https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.3.1
graal_install_root: "graalvm"
env:
# https://www.graalvm.org/21.3/reference-manual/native-image/Options/
# -H:NativeLinkerOption=-no-pie -> do not to generate Position Independent Executables (PIE)
NATIVE_IMAGE_ARGS:
-H:NativeLinkerOption=-no-pie
-H:ReflectionConfigurationFiles=picocli-reflections.json
-H:Log=registerResource:3
-H:+ReportExceptionStackTraces
-H:+RemoveUnusedSymbols
-H:ExcludeResources=com/sun/.*.properties
--exclude-config copycat-fat.jar META-INF/native-image/net.sf.jstuff/.*.json
--exclude-config copycat-fat.jar META-INF/native-image/jansi/.*.json
--allow-incomplete-classpath
--no-fallback
--no-server
--verbose
-Dfile.encoding=UTF-8
--class-path native-image-metadata
--class-path copycat-fat.jar
com.vegardit.copycat.CopyCatMain
copycat-${{ matrix.arch }}
steps:
- name: "Cache: GraalVM binaries"
uses: actions/cache@v4
with:
path: |
${{ matrix.graal_install_root }}
key: ${{ matrix.arch }}-graalvm-${{ matrix.graal_version }}
- name: "Create arm64 container"
if: matrix.arch == 'linux-arm64'
run: |
sudo apt-get update -y
sudo apt-get install --no-install-recommends -y qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker container create --name arm64 --tty \
--platform linux/arm64 \
-v /opt:/opt:rw \
-v $PWD:/workspace:rw \
arm64v8/ubuntu:24.04
docker container start arm64
docker exec --tty arm64 apt-get update -y
docker exec --tty arm64 apt-get install -y curl sudo
- name: "Install: GraalVM"
run: |
set -eu
case "${{ matrix.arch }}" in
linux-amd64)
sudo apt-get install --no-install-recommends -y gcc g++ libz-dev
GRAAL_VM_HOME=${{ matrix.graal_install_root }}
if [ ! -e $GRAAL_VM_HOME/bin/native-image ]; then
rm -rf $GRAAL_VM_HOME
mkdir -p $GRAAL_VM_HOME
curl -fL "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal_version }}/graalvm-ce-java${{ env.JAVA_VERSION}}-linux-amd64-${{ matrix.graal_version }}.tar.gz" \
| tar zxv -C $GRAAL_VM_HOME --strip-components=1 \
--exclude=*/bin/jvisualvm \
--exclude=*/lib/src.zip \
--exclude=*/lib/visualvm
$GRAAL_VM_HOME/bin/gu install native-image
fi
$GRAAL_VM_HOME/bin/native-image --version
echo "JAVA_HOME=$GRAAL_VM_HOME" >> $GITHUB_ENV
echo "$GRAAL_VM_HOME/bin" >> $GITHUB_PATH
;;
linux-arm64)
cat <<EOF > install_graalvm.sh
set -eu
sudo apt-get install --no-install-recommends -y gcc g++ libz-dev
GRAAL_VM_HOME=${{ matrix.graal_install_root }}
if [ ! -e \$GRAAL_VM_HOME/bin/native-image ]; then
rm -rf \$GRAAL_VM_HOME
mkdir -p \$GRAAL_VM_HOME
curl -fL "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal_version }}/graalvm-ce-java${{ env.JAVA_VERSION }}-linux-aarch64-${{ matrix.graal_version }}.tar.gz" \
| tar zxv -C \$GRAAL_VM_HOME --strip-components=1 \
--exclude=*/bin/jvisualvm \
--exclude=*/lib/src.zip \
--exclude=*/lib/visualvm
\$GRAAL_VM_HOME/bin/gu install native-image
fi
\$GRAAL_VM_HOME/bin/native-image --version
EOF
docker exec --tty -w /workspace arm64 /bin/bash ./install_graalvm.sh
;;
darwin-arm64)
GRAAL_VM_HOME=${{ matrix.graal_install_root }}/Contents/Home
if [ ! -e $GRAAL_VM_HOME/bin/native-image ]; then
rm -rf ${{ matrix.graal_install_root }}
mkdir ${{ matrix.graal_install_root }}
curl -fL "https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${{ matrix.graal_version }}/graalvm-community-jdk-${{ matrix.graal_version }}_macos-aarch64_bin.tar.gz" \
| tar zxv -C graalvm --strip-components=1 \
--exclude=*/bin/jvisualvm \
--exclude=*/lib/src.zip \
--exclude=*/lib/visualvm
fi
$GRAAL_VM_HOME/bin/native-image --version
echo "JAVA_HOME=$GRAAL_VM_HOME" >> $GITHUB_ENV
echo "$GRAAL_VM_HOME/bin" >> $GITHUB_PATH
;;
darwin-amd64)
GRAAL_VM_HOME=${{ matrix.graal_install_root }}/Contents/Home
if [ ! -e $GRAAL_VM_HOME/bin/native-image ]; then
rm -rf ${{ matrix.graal_install_root }}
mkdir ${{ matrix.graal_install_root }}
curl -fL "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal_version }}/graalvm-ce-java${{ env.JAVA_VERSION }}-darwin-amd64-${{ matrix.graal_version }}.tar.gz" \
| tar zxv -C graalvm --strip-components=1 \
--exclude=*/bin/jvisualvm \
--exclude=*/lib/src.zip \
--exclude=*/lib/visualvm
$GRAAL_VM_HOME/bin/gu install native-image
fi
$GRAAL_VM_HOME/bin/native-image --version
echo "JAVA_HOME=$GRAAL_VM_HOME" >> $GITHUB_ENV
echo "$GRAAL_VM_HOME/bin" >> $GITHUB_PATH
;;
windows-amd64)
GRAAL_VM_HOME=${{ matrix.graal_install_root }}
if [ ! -e $GRAAL_VM_HOME/bin/native-image ]; then
rm -rf $GRAAL_VM_HOME
echo "Downloading GraalVM..."
curl -fL -o graalvm.zip https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal_version }}/graalvm-ce-java${{ env.JAVA_VERSION }}-windows-amd64-${{ matrix.graal_version }}.zip
echo "Extracting GraalVM..."
7z x graalvm.zip
mv graalvm-ce-* $GRAAL_VM_HOME
$GRAAL_VM_HOME/bin/gu.cmd install native-image
fi
$GRAAL_VM_HOME/bin/native-image.cmd --version
echo "JAVA_HOME=$(cygpath -wa $GRAAL_VM_HOME)" >> $GITHUB_ENV
echo "$(cygpath -wa $GRAAL_VM_HOME/bin)" >> $GITHUB_PATH
;;
esac
- name: "Install: binutils (strip)"
run: |
case "${{ matrix.arch }}" in
linux-amd64)
sudo apt-get --no-install-recommends install -y binutils
;;
linux-arm64)
docker exec --tty arm64 \
sudo apt-get --no-install-recommends install -y binutils
;;
esac
- name: "Install: UPX"
env:
GITHUB_TOKEN: ${{ github.token }}
if: runner.os != 'macOS' # https://github.com/upx/upx/issues/612
run: |
case "${{ matrix.arch }}" in
linux-amd64)
if [[ ! -x /opt/upx/upx ]]; then # check for re-running a job in nektos/act
rm -rf /opt/upx
mkdir /opt/upx
upx_download_url=$(curl -fsSL ${GITHUB_TOKEN:+-H "Authorization: token $GITHUB_TOKEN"} https://api.github.com/repos/upx/upx/releases/latest | grep browser_download_url | grep amd64_linux.tar.xz | cut "-d\"" -f4)
echo "Downloading [$upx_download_url]..."
curl -fL $upx_download_url | tar Jxv -C /opt/upx --strip-components=1
fi
;;
linux-arm64)
if [[ ! -x /opt/upx/upx ]]; then # check for re-running a job in nektos/act
rm -rf /opt/upx
mkdir /opt/upx
upx_download_url=$(curl -fsSL ${GITHUB_TOKEN:+-H "Authorization: token $GITHUB_TOKEN"} https://api.github.com/repos/upx/upx/releases/latest | grep browser_download_url | grep arm64_linux.tar.xz | cut "-d\"" -f4)
echo "Downloading [$upx_download_url]..."
curl -fL $upx_download_url | tar Jxv -C /opt/upx --strip-components=1
fi
;;
darwin-*)
# https://github.com/Homebrew/homebrew-core/pull/183634
brew install upx
;;
windows-amd64)
# first choco install in a build takes 3+ minutes
# choco install -y upx
upx_download_url=$(curl -fsSL ${GITHUB_TOKEN:+-H "Authorization: token $GITHUB_TOKEN"} https://api.github.com/repos/upx/upx/releases/latest | grep browser_download_url | grep win64.zip | cut "-d\"" -f4)
echo "Downloading [$upx_download_url]..."
curl -fL -o /tmp/upx.zip $upx_download_url
echo "Extracting upx.zip..."
mkdir /tmp/upx
7z e /tmp/upx.zip -o/tmp/upx *.exe -r
echo "$(cygpath -wa /tmp/upx)" >> $GITHUB_PATH
;;
esac
- name: Enable Developer Command Prompt
if: matrix.arch == 'windows-amd64'
# makes cl.exe available on PATH
# https://github.com/marketplace/actions/enable-developer-command-prompt
uses: ilammy/msvc-dev-cmd@v1
- name: "Get: maven-build-artifacts"
uses: actions/download-artifact@v4
with:
name: maven-build-artifacts
- name: "Collect metadata"
run: |
set -eu
# https://www.graalvm.org/22.3/reference-manual/native-image/metadata/AutomaticMetadataCollection/#tracing-agent
cat <<'EOF' > collect_metadata.sh
set -eu
rm -rf native-image-metadata
function traceCall() {
echo "Tracing copycat ${@}..."
java -agentlib:native-image-agent=config-merge-dir=native-image-metadata/META-INF/native-image/ -jar copycat-fat.jar ${@} >/dev/null
}
rm -rf workdir
mkdir -p workdir/source/dir1
touch workdir/source/dir1/file1
traceCall sync workdir/source workdir/target
traceCall --help
traceCall --help
traceCall --version
traceCall sync --help
traceCall watch --help
EOF
case "${{ matrix.arch }}" in
linux-arm64)
docker exec --tty -w /workspace arm64 /bin/bash -c "
export JAVA_HOME=${{ matrix.graal_install_root }}
export PATH=${{ matrix.graal_install_root }}/bin:\$PATH
bash collect_metadata.sh
"
;;
*)
bash collect_metadata.sh
;;
esac
- name: "Build executable"
run: |
case "${{ matrix.arch }}" in
linux-amd64)
/usr/bin/gcc -v
native-image \
-H:+StaticExecutableWithDynamicLibC `# https://www.graalvm.org/21.3/reference-manual/native-image/StaticImages/#build-mostly-static-native-image` \
--report-unsupported-elements-at-runtime `# avoid: Unsupported type sun.awt.X11.XBaseWindow is reachable` \
${{ env.NATIVE_IMAGE_ARGS }}
;;
linux-arm64)
docker exec --tty -w /workspace arm64 /bin/bash -c "
export JAVA_HOME=${{ matrix.graal_install_root }}
export PATH=${{ matrix.graal_install_root }}/bin:\$PATH
/usr/bin/gcc -v
native-image \
-H:+StaticExecutableWithDynamicLibC `# https://www.graalvm.org/21.3/reference-manual/native-image/StaticImages/#build-mostly-static-native-image` \
--report-unsupported-elements-at-runtime `# avoid: Unsupported type sun.awt.X11.XBaseWindow is reachable` \
-Djdk.lang.Process.launchMechanism=vfork `# https://github.com/oracle/graal/issues/4143`\
-H:-CheckToolchain `#https://github.com/oracle/graal/issues/4143`\
${{ env.NATIVE_IMAGE_ARGS }}
"
;;
darwin-*)
# not using "--static" because of error: DARWIN does not support building static executable images.
native-image ${{ env.NATIVE_IMAGE_ARGS }}
;;
windows-amd64)
# https://www.graalvm.org/21.3/reference-manual/native-image/StaticImages/
native-image.cmd --static ${{ env.NATIVE_IMAGE_ARGS }}
;;
esac
- name: "Test executable"
run: |
case "${{ matrix.arch }}" in
linux-arm64)
docker exec --tty -w /workspace arm64 /bin/bash -c "
chmod u+x copycat-${{ matrix.arch }} &&
./copycat-${{ matrix.arch }} --version &&
./copycat-${{ matrix.arch }} --help &&
./copycat-${{ matrix.arch }} sync --help &&
./copycat-${{ matrix.arch }} watch --help
"
;;
*)
chmod u+x copycat-${{ matrix.arch }}
./copycat-${{ matrix.arch }} --version
./copycat-${{ matrix.arch }} --help
./copycat-${{ matrix.arch }} sync --help
./copycat-${{ matrix.arch }} watch --help
;;
esac
- name: "Compress executable"
if: runner.os != 'macOS' # https://github.com/upx/upx/issues/612
run: |
set -eu
case "${{ matrix.arch }}" in
linux-amd64)
strip --strip-unneeded copycat-${{ matrix.arch }}
/opt/upx/upx -v -9 --no-progress copycat-${{ matrix.arch }}
;;
linux-arm64)
docker exec --tty -w /workspace arm64 /bin/bash -c "
strip --strip-unneeded copycat-${{ matrix.arch }} &&
/opt/upx/upx -v -9 --no-progress copycat-${{ matrix.arch }}
"
;;
darwin-*)
# https://www.unix.com/man-page/osx/1/strip/
strip copycat-${{ matrix.arch }}
upx -v -9 --force-macos --no-progress copycat-${{ matrix.arch }}
;;
windows-amd64)
cp copycat-${{ matrix.arch }}.exe copycat-${{ matrix.arch }}-upx.exe
upx -v -9 --no-progress copycat-${{ matrix.arch }}-upx.exe
;;
esac
- name: "Test compressed executable"
if: runner.os != 'macOS' # https://github.com/upx/upx/issues/612
run: |
case "${{ matrix.arch }}" in
linux-arm64)
docker exec --tty -w /workspace arm64 /bin/bash -c "
chmod u+x copycat-${{ matrix.arch }} &&
./copycat-${{ matrix.arch }} --version &&
./copycat-${{ matrix.arch }} --help &&
./copycat-${{ matrix.arch }} sync --help &&
./copycat-${{ matrix.arch }} watch --help
"
;;
windows-*)
chmod u+x copycat-${{ matrix.arch }}-upx
./copycat-${{ matrix.arch }}-upx --version
./copycat-${{ matrix.arch }}-upx --help
./copycat-${{ matrix.arch }}-upx sync --help
./copycat-${{ matrix.arch }}-upx watch --help
;;
*)
chmod u+x copycat-${{ matrix.arch }}
./copycat-${{ matrix.arch }} --version
./copycat-${{ matrix.arch }} --help
./copycat-${{ matrix.arch }} sync --help
./copycat-${{ matrix.arch }} watch --help
;;
esac
- name: "Share: native binary"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.arch }}
path: copycat-${{ matrix.arch }}*
###########################################################
publish-release:
###########################################################
runs-on: ubuntu-latest
needs:
- native-image
if: ${{ github.ref_name == 'main' && !github.event.act }}
steps:
- name: "SCM Checkout"
# only required by "hub release create" to prevent "fatal: Not a git repository"
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: "Get: all build artifacts"
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: "Delete previous '${{ env.RELEASE_NAME }}' release"
if: env.RELEASE_NAME == 'latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://cli.github.com/manual/gh_release_delete
run: |
GH_DEBUG=1 gh release delete "$RELEASE_NAME" --yes --cleanup-tag || true
- name: "Create '${{ env.RELEASE_NAME }}' Release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://cli.github.com/manual/gh_release_create
run: |
GH_DEBUG=1 gh release create "$RELEASE_NAME" \
--latest \
--title "$RELEASE_NAME" \
--notes "${{ github.event.head_commit.message }}" \
--target "${{ github.sha }}" \
artifacts/copycat-fat.jar#copycat-${{ env.RELEASE_NAME }}-fat.jar \
artifacts/bash/bashcompletion.sh#copycat-${{ env.RELEASE_NAME }}-bashcompletion.sh \
artifacts/copycat-linux-amd64#copycat-${{ env.RELEASE_NAME }}-linux-amd64 \
artifacts/copycat-linux-arm64#copycat-${{ env.RELEASE_NAME }}-linux-arm64 \
artifacts/copycat-darwin-amd64#copycat-${{ env.RELEASE_NAME }}-darwin-amd64 \
artifacts/copycat-darwin-arm64#copycat-${{ env.RELEASE_NAME }}-darwin-arm64 \
artifacts/copycat-windows-amd64.exe#copycat-${{ env.RELEASE_NAME }}-windows-amd64.exe \
artifacts/copycat-windows-amd64-upx.exe#copycat-${{ env.RELEASE_NAME }}-windows-amd64-upx.exe
- name: "Delete intermediate build artifacts"
uses: geekyeggo/delete-artifact@v5 # https://github.com/GeekyEggo/delete-artifact/
with:
name: "*"
failOnError: false