-
Notifications
You must be signed in to change notification settings - Fork 1
562 lines (484 loc) · 17.5 KB
/
gg.yml
File metadata and controls
562 lines (484 loc) · 17.5 KB
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
on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize, closed ]
branches: [ main ]
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}-${{ github.event_name }}"
cancel-in-progress: true
name: gg.cmd
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Generate version
if: github.event.pull_request.merged == true
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{ github.token }}
- name: Set version
id: version
run: |
if [ "${{github.event.pull_request.merged}}" == "true" ]; then
echo "version=${{ steps.buildnumber.outputs.build_number }}" >> $GITHUB_OUTPUT
else
echo "version=dev" >> $GITHUB_OUTPUT
fi
stage4-OS:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-14
target: aarch64-apple-darwin
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-musl
- os: macos-15-intel
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
needs: version
steps:
- uses: actions/checkout@v6
- name: Prepare build
shell: bash
run: |
if [[ "${{ matrix.os }}" == *"ubuntu"* ]]
then
sudo apt-get -y update
sudo apt-get -y install musl-dev musl-tools
export CC=musl-gcc
fi
rustup update
rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: "stage42"
- name: Build
shell: bash
run: |
mkdir -p stage42
mv src/stage4/* stage42
rm -rf src
cd stage42
export VERSION=${{needs.version.outputs.version}}
cargo test
cargo build --release --target=${{ matrix.target }}
find . -type f -name stage4.exe -exec cp {} ../stage4 \;
find . -type f -name stage4 -exec cp {} ../stage4 \;
strip ../stage4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: stage4_${{ matrix.target }}
path: stage4
hash:
needs: [ stage4-OS ]
runs-on: ubuntu-latest
outputs:
has_secret: ${{ steps.check.outputs.has_secret }}
steps:
- name: Check for secret
id: check
run: echo "has_secret=${{ secrets.ConnectionString != '' }}" >> $GITHUB_OUTPUT
- name: Download stage4 hash
uses: actions/download-artifact@v8
- name: Rename to hash
shell: bash
run: |
mkdir hash
mkdir out
touch hashes
for dir in stage4_*
do
file=$dir/stage4
hash=$(sha512sum $file | awk '{ print $1 }')
cp $file out/$hash
echo $hash > hash/hash_$dir
echo $dir=$hash >> hashes
done
- name: Upload hash artifact
uses: actions/upload-artifact@v4
with:
name: hash
path: hash
- name: Upload hash artifact
uses: actions/upload-artifact@v4
with:
name: hashes
path: hashes
- uses: LanceMcCarthy/Action-AzureBlobUpload@v3
if: steps.check.outputs.has_secret == 'true'
with:
connection_string: ${{ secrets.ConnectionString }}
container_name: $web
source_folder: out
stage3-OS:
needs: hash
strategy:
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
stage4: x86_64-unknown-linux-musl
- os: ubuntu-22.04
target: x86_64-unknown-linux-musl
stage4: x86_64-unknown-linux-musl
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-musl
stage4: aarch64-unknown-linux-musl
- os: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
stage4: aarch64-unknown-linux-musl
- os: macos-14
target: aarch64-apple-darwin
stage4: aarch64-apple-darwin
- os: macos-15-intel
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Download stage4 hash
uses: actions/download-artifact@v8
with:
name: hash
path: hash
- name: Hash
# ENV -> CMAKE -> Code very hard. This very easy
shell: bash
run: |
hash=$(cat hash/hash_stage4_${{ matrix.stage4 }})
echo "now hash is $hash"
echo "const char *hash = \"$hash\";" > src/stage3/const.h
- name: Makus
shell: bash
run: |
set -x
cd src/stage3
if [[ "${{ matrix.target }}" == *"musl"* ]]
then
sudo apt-get -y update
sudo apt-get -y install musl-dev musl-tools
export CC=musl-gcc
fi
cmake -B build -DCMAKE_EXE_LINKER_FLAGS='-Os' -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
find . -type f \( -name stage3 -o -name stage3.exe \) -exec cp {} ../../stage3_${{ matrix.target }} \;
strip ../../stage3_${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: stage3_${{ matrix.target }}
path: stage3_${{ matrix.target }}
stage1:
needs: [ version, stage3-OS ]
runs-on: ubuntu-latest
steps:
- name: Source
uses: actions/checkout@v6
- name: Download stage3 / stage4
uses: actions/download-artifact@v8
- name: gg.cmd
run: |
sudo apt-get install dos2unix
mv src/stage1 _stage1
mv src/stage2 _stage2
mv src/stage3 _stage3
VERSION=${{needs.version.outputs.version}}
rm -rf gg-$VERSION
mkdir -p gg-$VERSION
rm -rf src
for dir in stage3*; do
for file in "$dir"/*; do
cp "$file" gg-$VERSION/
done
done
# Prevent wine from trying to run (if installed on users PC)
# mv .cache/gg/stage3_x86_64-pc-windows-msvc .cache/gg/stage3_zz_x86_64-pc-windows-msvc
sed -i "s/VERVER/$VERSION/g" _stage2/stage2.*
cp _stage2/stage2.sh gg-$VERSION/
cp _stage2/stage2.ps1 gg-$VERSION/
cp hashes/hashes gg-$VERSION/
chmod +x gg-$VERSION/stage2.sh
tar -zpvcf gg.tgz gg-$VERSION
sed -i "s/VERVER/$VERSION/g" _stage1/stage1.*
unix2dos _stage1/stage1.bat
cat _stage1/stage1.bat _stage1/stage1.sh > 1
a=$(du -cb 1 | tail -n 1 | awk '{print $1}')
b=a
((b++))
sed -i "s/AAAA/$a/" 1;
sed -i "s/BBBB/$b/" 1;
cat 1 gg.tgz > gg.cmd
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gg.cmd
path: gg.cmd
test-OS1:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ ubuntu-22.04, windows-2022 ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "deno -V", "caddy -v", "jbang --version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fortio version", "fastlane --version", "gh/mozilla/sccache -V" ]
include:
- os: ubuntu-22.04
stage4_target: x86_64-unknown-linux-musl
- os: windows-2022
stage4_target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
if [[ "${{ runner.os }}" == "Windows" ]]; then
cp stage4 "$HOME/.cache/gg/gg-dev/stage4.exe"
else
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
fi
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
# Not all tools work on all OSes :/
test-OS2:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ macos-14, macos-15-intel ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "deno -V", "jbang --version", "gh/cli/cli version", "gh version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fastlane --version" ]
include:
- os: macos-14
stage4_target: aarch64-apple-darwin
- os: macos-15-intel
stage4_target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
test-OS3:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ ubuntu-22.04-arm, macos-14, macos-15-intel ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "deno -V", "jbang --version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fastlane --version" ]
include:
- os: ubuntu-22.04-arm
stage4_target: aarch64-unknown-linux-musl
- os: macos-14
stage4_target: aarch64-apple-darwin
- os: macos-15-intel
stage4_target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_${{ matrix.stage4_target }}
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="${{ matrix.stage4_target }}"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM="${SYSTEM/musl/gnu}"; fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
shell: bash
run: |
set -x
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
test-batch:
needs: [ stage1, hash ]
strategy:
matrix:
os: [ windows-2022 ]
cmd: [ "node -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "deno -V", "caddy -v", "jbang --version", "gh/cli/cli version", "gh version", "just -V", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "fortio version", "fastlane --version", "gh/mozilla/sccache -V" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_x86_64-pc-windows-msvc
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
shell: bash
run: |
mkdir -p "$USERPROFILE/.cache/gg/gg-dev"
echo "x86_64-pc-windows-msvc" > "$USERPROFILE/.cache/gg/gg-dev/system"
cp stage4 "$USERPROFILE/.cache/gg/gg-dev/stage4.exe"
- name: Run!
shell: cmd
run: |
.\gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
.\gg.cmd -v ${{ matrix.cmd }}
- name: Test version flag
shell: cmd
run: |
.\gg.cmd -V
echo Exit code was %errorlevel%
test-container:
needs: [ stage1, hash ]
strategy:
matrix:
container: [ ubuntu, debian, alpine, archlinux ]
cmd: [ "node@14 -v", "java -version", "gradle -version", "openapi version", "run:java@14 java -version", "run:java@21-azul java -version", "run:java@21-tem java -version", "run:java@17-tem java -version", "just -V", "fortio version", "gh/mozilla/sccache -V" ]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Download stage4
if: needs.hash.outputs.has_secret != 'true'
uses: actions/download-artifact@v8
with:
name: stage4_x86_64-unknown-linux-musl
- name: Pre-populate cache with stage4
if: needs.hash.outputs.has_secret != 'true'
run: |
mkdir -p "$HOME/.cache/gg/gg-dev"
SYSTEM="x86_64-unknown-linux-musl"
if getconf GNU_LIBC_VERSION >/dev/null 2>&1; then SYSTEM=$(echo "$SYSTEM" | sed 's/musl/gnu/'); fi
echo "$SYSTEM" > "$HOME/.cache/gg/gg-dev/system"
cp stage4 "$HOME/.cache/gg/gg-dev/stage4"
chmod +x "$HOME/.cache/gg/gg-dev/stage4"
- name: Run!
run: |
set -x
# This is required for nodejs to run - not gg.cmd!
if [ "${{ matrix.container }}" == "alpine" ]; then
apk add libstdc++
fi
sh gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
sh gg.cmd -v ${{ matrix.cmd }}
# GitHub Actions hate me :/
gatekeeper:
needs: [ test-OS1, test-OS2, test-OS3, test-batch, test-container ]
runs-on: ubuntu-latest
if: always()
steps:
- name: Fail if any test job failed or was skipped
run: |
echo "Checking test job results..."
FAILED=0
echo "test-OS1: ${{ needs.test-OS1.result }}"
if [ "${{ needs.test-OS1.result }}" != "success" ]; then FAILED=1; fi
echo "test-OS2: ${{ needs.test-OS2.result }}"
if [ "${{ needs.test-OS2.result }}" != "success" ]; then FAILED=1; fi
echo "test-OS3: ${{ needs.test-OS3.result }}"
if [ "${{ needs.test-OS3.result }}" != "success" ]; then FAILED=1; fi
echo "test-batch: ${{ needs.test-batch.result }}"
if [ "${{ needs.test-batch.result }}" != "success" ]; then FAILED=1; fi
echo "test-container: ${{ needs.test-container.result }}"
if [ "${{ needs.test-container.result }}" != "success" ]; then FAILED=1; fi
if [ $FAILED -eq 1 ]; then
echo "::error::One or more test jobs failed or were skipped"
exit 1
fi
echo "All test jobs passed successfully"
release:
name: Release!
needs: [ version, gatekeeper ]
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ needs.version.outputs.version }}
release_name: ${{ needs.version.outputs.version }}
body: ${{ github.event.pull_request.body }}
- name: Download gg
uses: actions/download-artifact@v8
with:
name: gg.cmd
- name: Prepare upload
shell: bash
run: |
set -x
mkdir to_blob
cp gg.cmd to_blob
- uses: LanceMcCarthy/Action-AzureBlobUpload@v3
with:
connection_string: ${{ secrets.ConnectionString }}
container_name: $web
source_folder: to_blob
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token}}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gg.cmd
asset_name: gg.cmd
asset_content_type: text/x-shellscript