-
Notifications
You must be signed in to change notification settings - Fork 0
415 lines (353 loc) · 11.1 KB
/
gg.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
on:
workflow_dispatch:
push:
branches-ignore:
- main
pull_request:
types: [ closed ]
branches: [ main ]
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: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: buildjet-2vcpu-ubuntu-2204-arm
target: aarch64-unknown-linux-musl
runs-on: ${{ matrix.os }}
needs: version
steps:
- uses: actions/checkout@v2
- 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@v2
with:
name: stage4_${{ matrix.target }}
path: stage4
hash:
needs: [ stage4-OS ]
runs-on: ubuntu-20.04
steps:
- name: Download stage4 hash
uses: actions/download-artifact@v2
- 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@v2
with:
name: hash
path: hash
- name: Upload hash artifact
uses: actions/upload-artifact@v2
with:
name: hashes
path: hashes
- uses: LanceMcCarthy/Action-AzureBlobUpload@v2
with:
connection_string: ${{ secrets.ConnectionString }}
container_name: $web
source_folder: out
stage3-OS:
needs: hash
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
# TODO: Version too new
- os: macos-12
target: x86_64-apple-darwin
stage4: x86_64-apple-darwin
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
stage4: x86_64-unknown-linux-musl
- os: ubuntu-20.04
target: x86_64-unknown-linux-musl
stage4: x86_64-unknown-linux-musl
- os: buildjet-2vcpu-ubuntu-2204-arm
target: aarch64-unknown-linux-musl
stage4: aarch64-unknown-linux-musl
- os: buildjet-2vcpu-ubuntu-2204-arm
target: aarch64-unknown-linux-gnu
stage4: aarch64-unknown-linux-musl
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Download stage4 hash
uses: actions/download-artifact@v2
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@v2
with:
name: stage3_${{ matrix.target }}
path: stage3_${{ matrix.target }}
stage1:
needs: [ version, stage3-OS ]
runs-on: ubuntu-latest
steps:
- name: Source
uses: actions/[email protected]
- name: Download stage3 / stage4
uses: actions/download-artifact@v2
- 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 .cache/gg/gg-$VERSION
mkdir -p .cache/gg/gg-$VERSION
rm -rf src
for dir in stage3*; do
for file in "$dir"/*; do
cp "$file" .cache/gg/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 .cache/gg/gg-$VERSION/
cp _stage2/stage2.ps1 .cache/gg/gg-$VERSION/
cp hashes/hashes .cache/gg/gg-$VERSION/
chmod +x .cache/gg/gg-$VERSION/stage2.sh
tar -zpvcf gg.tgz .cache
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/AAA/$a/" 1;
sed -i "s/BBB/$b/" 1;
cat 1 gg.tgz > gg.cmd
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: gg.cmd
path: gg.cmd
test-OS:
needs: stage1
strategy:
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macOS-11, macOS-12 ]
cmd: [ "node -v", "java -version", "gradle -version", "maven -v", "openapi version", "rat -V", "run:java@14 java -version", "deno -V" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v2
with:
name: gg.cmd
- 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-ARM:
needs: stage1
strategy:
matrix:
os: [ buildjet-2vcpu-ubuntu-2204-arm ]
cmd: [ "java -version" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v2
with:
name: gg.cmd
- 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
strategy:
matrix:
os: [ windows-2019, windows-2022 ]
cmd: [ "node -v", "java -version", "gradle -version", "maven -v", "openapi version", "rat -V", "run:java@14 java -version", "deno -V" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v2
with:
name: gg.cmd
- name: Run!
shell: cmd
run: |
.\gg.cmd -v ${{ matrix.cmd }}
echo "Nice, let's try again"
.\gg.cmd -v ${{ matrix.cmd }}
test-ARM-container:
needs: stage1
strategy:
matrix:
os: [ buildjet-2vcpu-ubuntu-2204-arm ]
container: [ alpine ]
cmd: [ "java -version" ]
runs-on: ${{ matrix.os }}
steps:
- name: Download gg
uses: actions/download-artifact@v3
with:
name: gg.cmd
- name: Run!
run: |
set -x
uname -a
docker run --rm -i -v $PWD:/b -w /b ${{ matrix.container }} sh gg.cmd -v ${{ matrix.cmd }}
test-container:
needs: stage1
strategy:
matrix:
container: [ ubuntu, debian, alpine, archlinux ]
cmd: [ "node@14 -v", "java -version", "gradle -version", "maven -v", "openapi version", "rat -V", "run:java@14 java -version" ]
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- name: Download gg
uses: actions/download-artifact@v2
with:
name: gg.cmd
- 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 }}
release:
name: Release!
needs: [ version, test-OS, test-batch, test-container ]
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@v2
with:
name: gg.cmd
- name: Prepare upload
shell: bash
run: |
set -x
mkdir to_blob
cp gg.cmd to_blob
- uses: LanceMcCarthy/Action-AzureBlobUpload@v2
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