-
Notifications
You must be signed in to change notification settings - Fork 107
413 lines (344 loc) · 14 KB
/
main.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
name: CI
on: [push, pull_request]
env:
NEKO_VERSION: 2.4.0
jobs:
linux-build:
name: linux
strategy:
matrix:
arch: [arm64, amd64]
link_type: [static, dynamic]
include:
- link_type: static
name_suffix: -static
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Earthly
run: sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly && /usr/local/bin/earthly bootstrap --with-autocomplete'
- name: Install QEMU
run: |
sudo apt-get install qemu binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker stop earthly-buildkitd || true
- name: Build package
run: earthly --platform=linux/${{ matrix.arch }} +package --LINK_TYPE=${{ matrix.link_type }}
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: linux${{ matrix.name_suffix }}-${{ matrix.arch }}-binaries
path: bin/${{ matrix.link_type }}/linux/${{ matrix.arch }}/neko-${{ env.NEKO_VERSION }}-linux*.tar.gz
mac-build:
name: mac
strategy:
matrix:
arch: [arm64, amd64]
link_type: [static, dynamic]
include:
- arch: arm64
os: macos-14
- arch: amd64
os: macos-13
- link_type: static
BREWFILE: extra/Brewfile-STATIC_DEPS_ALL
STATIC_DEPS: all
name_suffix: -static
- link_type: dynamic
BREWFILE: extra/Brewfile-STATIC_DEPS_NONE
STATIC_DEPS: none
runs-on: ${{ matrix.os }}
env:
CMAKE_BUILD_TYPE: RelWithDebInfo
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Homebrew dependencies
run: |
set -ex
brew update
brew bundle --file="${{ matrix.BREWFILE }}"
- name: CMake
run: cmake . -DSTATIC_DEPS=${{ matrix.STATIC_DEPS }} -G Ninja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE
- name: Download dependencies
run: ninja download_deps || ninja download_deps || ninja download_deps
if: ${{ matrix.link_type == 'static' }}
- name: Build
run: ninja
- name: Check runtime dependencies
run: |
set -ex
otool -L ./bin/neko
otool -L ./bin/nekoc
otool -L ./bin/nekoml
otool -L ./bin/nekotools
- name: Test
run: ctest --verbose
- name: Package
run: ninja package
- name: Check version
shell: bash
run: |
set -ex
[ "`./bin/neko -version`" == "$NEKO_VERSION" ]
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: mac${{ matrix.name_suffix }}-${{ matrix.arch }}-binaries
path: bin/neko-${{ env.NEKO_VERSION }}-osx*.tar.gz
windows-build:
name: windows
strategy:
matrix:
arch: [Win32, x64]
vstools: [vs2017, vs2019]
include:
- arch: x64
name_suffix: 64
- vstools: vs2017
arch: Win32
cmake_generator: Visual Studio 15 2017
- vstools: vs2017
arch: x64
cmake_generator: Visual Studio 15 2017 Win64
- vstools: vs2019
cmake_generator: Visual Studio 16 2019
env:
CMAKE_BUILD_TYPE: RelWithDebInfo
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install VS2017 tools
run: |
choco install visualstudio2017buildtools visualstudio2017-workload-vctools
if: ${{ matrix.vstools == 'vs2017' }}
- name: CMake
run: |
cmake . -G "${{ matrix.cmake_generator }}" ${{ env.CMAKE_ARCH_FLAG }}
env:
CMAKE_ARCH_FLAG: ${{ matrix.vstools == 'vs2019' && format('-A {0}', matrix.arch) || ' ' }}
- name: Download dependencies
run: |
cmake --build . --config $env:CMAKE_BUILD_TYPE --target download_deps || \
cmake --build . --config $env:CMAKE_BUILD_TYPE --target download_deps || \
cmake --build . --config $env:CMAKE_BUILD_TYPE --target download_deps
- name: Build
run: cmake --build . --config $env:CMAKE_BUILD_TYPE
- name: Test
run: ctest --verbose --build-config $env:CMAKE_BUILD_TYPE
- name: Package binaries
run: cmake --build . --config $env:CMAKE_BUILD_TYPE --target PACKAGE
- name: Check version
shell: bash
run: |
set -ex
[ "`./bin/neko -version`" == "$NEKO_VERSION" ]
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: windows${{ matrix.name_suffix }}-${{ matrix.vstools }}-binaries
path: bin/neko-${{ env.NEKO_VERSION }}-win${{ matrix.name_suffix }}.zip
package-choco:
name: chocolatey
needs: [windows-build]
runs-on: windows-latest
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download windows-vs2017-binaries
uses: actions/download-artifact@v4
with:
name: windows-vs2017-binaries
path: windows-vs2017-binaries
- name: Download windows64-vs2017-binaries
uses: actions/download-artifact@v4
with:
name: windows64-vs2017-binaries
path: windows64-vs2017-binaries
- name: Prepare Chocolatey Package
run: |
.\extra\chocolatey\generatePackage.ps1 $env:NEKO_VERSION
Get-ChildItem extra\chocolatey\out
- name: Format package version string
run: |
$commitSha = git rev-parse --short HEAD
$commitTime = git show -s --format=%cI HEAD
$commitTime = $commitTime.substring(0,19) -replace '[^0-9]',''
$sourceBranch = '$(Build.SourceBranch)'
$chocoVersion = If ($sourceBranch.StartsWith('refs/tags/v')) {'$env:NEKO_VERSION'} Else {"$env:NEKO_VERSION-SNAP$commitTime"}
echo chocoVersion=$chocoVersion >> $env:GITHUB_ENV
- name: choco pack
run: choco pack --version $env:chocoVersion -Out ..\pack
working-directory: extra/chocolatey/out/
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: chocolatey
path: extra/chocolatey/pack/
mac-universal:
name: mac universal
needs: [mac-build]
runs-on: macos-latest
env:
INPUT_AMD64: mac-static-amd64-binaries
INPUT_ARM64: mac-static-arm64-binaries
steps:
- name: Download ${{ env.INPUT_AMD64 }}
uses: actions/download-artifact@v4
with:
name: ${{ env.INPUT_AMD64 }}
path: ${{ env.INPUT_AMD64 }}
- name: Download ${{ env.INPUT_ARM64 }}
uses: actions/download-artifact@v4
with:
name: ${{ env.INPUT_ARM64 }}
path: ${{ env.INPUT_ARM64 }}
- name: Create universal binaries
run: |
tar_filename_amd64=$(basename $INPUT_AMD64/neko-*-osx64.tar.gz .tar.gz)
OUTPUT=${tar_filename_amd64/osx64/osx-universal}
mkdir $OUTPUT
# put amd64 files straight into output to make sure all non-binary files are also included
tar -xf $INPUT_AMD64/neko-*.tar.gz \
-C $OUTPUT --strip-components=1
tar -xf $INPUT_ARM64/neko-*.tar.gz \
-C $INPUT_ARM64 --strip-components=1
for filename in $OUTPUT/{*.ndll,libneko.*.*.*.dylib,neko,nekoc,nekoml,nekotools}; do
filename_amd64=$filename
filename_arm64=${filename/$OUTPUT/$INPUT_ARM64}
lipo -create -output $filename $filename_amd64 $filename_arm64
done
file $OUTPUT/*
tar -czvf $OUTPUT.tar.gz $OUTPUT
- name: Upload universal binaries
uses: actions/upload-artifact@v4
with:
name: mac-static-universal-binaries
path: neko-*-osx-universal.tar.gz
deploy-s3:
name: deploy s3
needs: [windows-build, package-choco, mac-build, linux-build]
runs-on: ubuntu-latest
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download linux-static-amd64-binaries
uses: actions/download-artifact@v4
with:
name: linux-static-amd64-binaries
path: linux-static-amd64-binaries
- name: Download linux-static-arm64-binaries
uses: actions/download-artifact@v4
with:
name: linux-static-arm64-binaries
path: linux-static-arm64-binaries
- name: Download mac-static-amd64-binaries
uses: actions/download-artifact@v4
with:
name: mac-static-amd64-binaries
path: mac-static-amd64-binaries
- name: Download mac-static-arm64-binaries
uses: actions/download-artifact@v4
with:
name: mac-static-arm64-binaries
path: mac-static-arm64-binaries
- name: Download windows-vs2017-binaries
uses: actions/download-artifact@v4
with:
name: windows-vs2017-binaries
- name: Download windows64-vs2017-binaries
uses: actions/download-artifact@v4
with:
name: windows64-vs2017-binaries
- name: Download chocolatey
uses: actions/download-artifact@v4
with:
name: chocolatey
- name: Install awscli
run: |
set -ex
sudo apt-get update -qqy
sudo apt-get install -qqy awscli
# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
- name: Extract branch name
id: extract_branch
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Upload binaries
env:
AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
HXBUILDS_S3ADDR: ${{ vars.HXBUILDS_S3ADDR }}
run: |
set -ex
COMMIT_HASH=`git rev-parse HEAD`
COMMIT_HASH_SHORT=${GITHUB_SHA:0:7}
COMMIT_DATE=`TZ=UTC git show --quiet --date='format-local:%Y-%m-%d' --format="%cd"`
FILE_NAME=neko_${COMMIT_DATE}_${{ steps.extract_branch.outputs.branch }}_${COMMIT_HASH_SHORT}
aws s3 cp linux-static-amd64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/linux64/${FILE_NAME}.tar.gz
aws s3 cp linux-static-arm64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/linux-arm64/${FILE_NAME}.tar.gz
aws s3 cp mac-static-amd64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/mac/${FILE_NAME}.tar.gz
aws s3 cp mac-static-arm64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/mac-arm64/${FILE_NAME}.tar.gz
aws s3 cp neko-*-win.zip $HXBUILDS_S3ADDR/neko/windows/${FILE_NAME}.zip
aws s3 cp neko-*-win64.zip $HXBUILDS_S3ADDR/neko/windows64/${FILE_NAME}.zip
aws s3 cp neko.*.nupkg $HXBUILDS_S3ADDR/neko/windows64-choco/
- name: Update "latest"
if: github.ref == 'refs/heads/master'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.HXBUILDS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HXBUILDS_AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
HXBUILDS_S3ADDR: ${{ vars.HXBUILDS_S3ADDR }}
run: |
set -ex
aws s3 cp linux-static-amd64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/linux64/neko_latest.tar.gz
aws s3 cp linux-static-arm64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/linux-arm64/neko_latest.tar.gz
aws s3 cp mac-static-amd64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/mac/neko_latest.tar.gz
aws s3 cp mac-static-arm64-binaries/neko-*.tar.gz $HXBUILDS_S3ADDR/neko/mac-arm64/neko_latest.tar.gz
aws s3 cp neko-*-win.zip $HXBUILDS_S3ADDR/neko/windows/neko_latest.zip
aws s3 cp neko-*-win64.zip $HXBUILDS_S3ADDR/neko/windows64/neko_latest.zip
# Chocolatey packages have to be named with version number,
# so let's use web redirection to keep the original file name.
[[ "$HXBUILDS_S3ADDR" =~ s3://([^/]+)(.*) ]] && HXBUILDS_S3BUCKET="${BASH_REMATCH[1]}" && HXBUILDS_S3PATH="${BASH_REMATCH[2]}"
FILE_NAME=$(echo neko.*.nupkg)
aws s3 cp $HXBUILDS_S3ADDR/neko/windows64-choco/${FILE_NAME} $HXBUILDS_S3ADDR/neko/windows64-choco/neko_latest.nupkg --acl public-read --website-redirect "${HXBUILDS_S3PATH}/neko/windows64-choco/${FILE_NAME}"
deploy-ppa:
name: deploy ppa
needs: [windows-build, package-choco, mac-build, linux-build]
runs-on: ubuntu-latest
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
steps:
- name: Download haxeci_sec.gpg
run: '# TODO'
- name: Download haxeci_ssh
run: '# TODO'
- name: Setup credentials
run: |
# TODO
set -ex
chmod 600 $CREDENTIAL_PATH/haxeci_ssh
eval `ssh-agent -s`
ssh-add $CREDENTIAL_PATH/haxeci_ssh
gpg --allow-secret-key-import --import $CREDENTIAL_PATH/haxeci_sec.gpg
git config --global user.name "$DEBFULLNAME"
git config --global user.email "$DEBEMAIL"
env:
CREDENTIAL_PATH: . # TODO
DEBFULLNAME: ${{ secrets.DEBFULLNAME }}
DEBEMAIL: ${{ secrets.DEBEMAIL }}
- name: Install devscripts
run: |
set -ex
sudo apt-get update -qqy
sudo apt-get install -qqy ninja-build pkg-config libgtk-3-dev devscripts git-buildpackage ubuntu-dev-tools dh-make dh-apache2
- name: CMake
run: cmake . -DSTATIC_DEPS=all
- name: Upload to PPA
run: make upload_to_ppa