-
Notifications
You must be signed in to change notification settings - Fork 1
385 lines (342 loc) · 14.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
name: Build
run-name: "Branch Build (${{ github.run_attempt }}.${{ github.run_number }}) - ${{ github.ref_name }}"
on:
workflow_dispatch:
inputs:
amalgam-build:
description: |
(Optional) Amalgam build or version number. Defaults to pinned release.
Examples:
'6807310618',
'https://github.com/howsoai/amalgam/actions/runs/6807310618',
'57.0.1'
required: false
type: string
debug-mode:
description: Enables GDB and Amalgam Fast Memory Integrity checks for all Linux/x86 Pytest jobs.
type: boolean
required: false
default: false
workflow_call:
inputs:
build-type:
required: false
type: string
optional-release-tag:
required: false
type: string
debug-mode:
type: boolean
required: false
default: false
defaults:
run:
shell: bash
jobs:
metadata:
uses: howsoai/.github/.github/workflows/set-metadata.yml@main
secrets: inherit
with:
build-type: ${{ inputs.build-type }}
optional-release-tag: ${{ inputs.optional-release-tag }}
amalgam-build: ${{ inputs.amalgam-build }}
build:
name: Build (${{ matrix.plat }})
needs: ["metadata"]
runs-on: ubuntu-latest
strategy:
matrix:
plat: [manylinux_2_28_x86_64, manylinux_2_29_x86_64, manylinux_2_29_aarch64, macosx_12_0_x86_64, macosx_12_0_arm64, win_amd64, any]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel
run: >-
python3 -m
pip install
cibuildwheel==2.15.0
build
- name: Download Amalgam linux-amd64
if: matrix.plat == 'manylinux_2_29_x86_64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
# Release artifacts will have a .tar.gz postfix while branch/PR build artifacts will not
if [[ "$run_type" == "release" ]]; then
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64.tar.gz" "$run_id"
else
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64" "$run_id"
fi
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-amd64-228
# Linux version that supports GLIBC 2.28+, most users should use 2.29+ (above)
# This specifically does NOT run on the "any" platform target.
if: matrix.plat == 'manylinux_2_28_x86_64'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
if [[ "$run_type" == "release" ]]; then
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64-228.tar.gz" "$run_id"
else
gh $run_type download -D amalgam/lib/linux/amd64 -R "howsoai/amalgam" -p "amalgam-*-linux-amd64-228" "$run_id"
fi
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-arm64
if: matrix.plat == 'manylinux_2_29_aarch64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
if [[ "$run_type" == "run" ]]; then
pattern="*linux-arm64"
else
pattern="*linux-arm64.tar.gz"
fi
gh $run_type download -D amalgam/lib/linux/arm64 -R "howsoai/amalgam" -p "$pattern" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/arm64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam linux-arm64_8a
if: matrix.plat == 'manylinux_2_29_aarch64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/linux/arm64_8a -R "howsoai/amalgam" -p "*linux-arm64_8a*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/linux/arm64_8a && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam darwin-amd64
if: matrix.plat == 'macosx_12_0_x86_64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/darwin/amd64 -R "howsoai/amalgam" -p "*darwin-amd64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/darwin/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam darwin-arm64
if: matrix.plat == 'macosx_12_0_arm64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/darwin/arm64 -R "howsoai/amalgam" -p "*darwin-arm64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/darwin/arm64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Download Amalgam windows-amd64
if: matrix.plat == 'win_amd64' || matrix.plat == 'any'
env:
GH_TOKEN: ${{ github.token }}
run: |
run_id=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_id')
run_type=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".run_type')
gh $run_type download -D amalgam/lib/windows/amd64 -R "howsoai/amalgam" -p "*windows-amd64*" "$run_id"
# Needed because release/non-release downloads are different structure
cd amalgam/lib/windows/amd64 && if [ ! -f *.tar.gz ]; then mv */*.tar.gz ./; fi && tar -xvzf *.tar.gz
- name: Format lib dir and version.json
run: |
version_file=$(find "$(pwd)/amalgam/lib" -type f -name "version.json" | head -n1)
new_version_file="amalgam/lib/version.json"
if [ -f "${version_file}" ]; then
cp "${version_file}" $new_version_file
jq '{version: {amalgam: .version}}' $new_version_file > ${new_version_file}.tmp && mv ${new_version_file}.tmp ${new_version_file}
else
# Fall back to what is checked into repo:
cp version.json $new_version_file
sed -i 's/dependencies/version/g' $new_version_file
fi
cd amalgam/lib
find . -type d -name lib -exec sh -c 'mv {}/* "$(dirname {})"' \;
- name: Set amalgam version metadata
run: |
cd amalgam/lib
build_title=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".build_title')
build_date=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".build_date')
head_sha=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".head_sha')
url=$(printf "%s" '${{ needs.metadata.outputs.upstream-details }}' | jq -r '."amalgam".url')
jq --arg head_sha "$head_sha" '.version |= . + {"amalgam_sha": $head_sha}' version.json > temp.json && mv temp.json version.json
jq --arg url "$url" '.version |= . + {"amalgam_url": $url}' version.json > temp.json && mv temp.json version.json
jq --arg build_date "$build_date" '.version |= . + {"amalgam_build_date": $build_date}' version.json > temp.json && mv temp.json version.json
jq --arg build_title "$build_title" '.version |= . + {"amalgam_display_title": $build_title}' version.json > temp.json && mv temp.json version.json
cat version.json
- name: Build wheels
run: |
python3 -m build --wheel --outdir wheelhouse/ .
mkdir -p dist/
mv wheelhouse/*.whl dist/amalgam_lang-${{ needs.metadata.outputs.version }}-py3-none-${{ matrix.plat }}.whl
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.metadata.outputs.version }}
- name: Build tarball
if: matrix.plat == 'any'
run: |
python3 -m build --sdist --outdir dist/ .
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.metadata.outputs.version }}
- name: Upload Tarball Artifact
if: matrix.plat == 'any'
uses: actions/upload-artifact@v4
with:
name: amalgam_lang-${{ needs.metadata.outputs.version }}
path: dist/amalgam_lang-*.tar.gz
if-no-files-found: error
- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: amalgam_lang-${{ needs.metadata.outputs.version }}-py3-none-${{ matrix.plat }}
path: dist/amalgam_lang-*.whl
if-no-files-found: error
workflow-summary:
needs: ['metadata', 'build']
uses: "howsoai/.github/.github/workflows/workflow-summary.yml@main"
secrets: inherit
with:
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
pytest-linux-3-9-st:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'ubuntu-latest'
platform-pretty: 'Linux'
amalgam-plat-arch: 'linux-amd64'
python-version: '3.9'
config-fp: './config/latest-st-traces-howso.yml'
config-pretty: 'ST'
workers: 'auto'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-linux-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'ubuntu-latest'
platform-pretty: 'Linux'
amalgam-plat-arch: 'linux-amd64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-windows-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'windows-latest'
platform-pretty: 'Windows'
amalgam-plat-arch: 'windows-amd64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
pytest-macos-3-12-mt:
needs: ['metadata', 'build']
uses: howsoai/.github/.github/workflows/pytest.yml@main
secrets: inherit
with:
platform: 'macos-latest'
platform-pretty: 'MacOS'
amalgam-plat-arch: 'darwin-arm64'
python-version: '3.12'
config-fp: './config/latest-mt-traces-howso.yml'
config-pretty: 'MT'
upstream-details: ${{ needs.metadata.outputs.upstream-details }}
debug: ${{ inputs.debug-mode }}
publish:
if: inputs.build-type == 'release'
needs:
- metadata
- workflow-summary
- pytest-linux-3-9-st
- pytest-linux-3-12-mt
- pytest-macos-3-12-mt
- pytest-windows-3-12-mt
runs-on: ubuntu-latest
environment:
name: PyPi
permissions:
id-token: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Configure environment
run: |
mkdir -p dist
find ./tmp -type f -name '*.whl' -exec cp -t ./dist {} +
find ./tmp -type f -name '*.tar.gz' -exec cp -t ./dist {} +
ls ./dist
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Publish [PyPi]
uses: pypa/gh-action-pypi-publish@release/v1
with:
# Experimental feature not yet compatible with our workflow
attestations: False
generate-changelog:
if: inputs.build-type == 'release'
secrets: inherit
needs:
- metadata
uses: "howsoai/.github/.github/workflows/release-notes.yml@main"
release:
if: inputs.build-type == 'release'
needs:
- metadata
- generate-changelog
- workflow-summary
- pytest-linux-3-9-st
- pytest-linux-3-12-mt
- pytest-macos-3-12-mt
- pytest-windows-3-12-mt
- publish
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./tmp
- name: Clean up dir
run: |
mkdir -p dist
find ./tmp -type f -name '*.whl' -exec mv -t ./dist {} +
find ./tmp -type f -name '*.tar.gz' -exec mv -t ./dist {} +
ls ./dist
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.metadata.outputs.version }}
commit: ${{ github.sha }}
name: "${{ github.event.repository.name }} ${{ needs.metadata.outputs.version }}"
artifactErrorsFailBuild: true
body: ${{ needs.generate-changelog.outputs.changelog }}
makeLatest: legacy
artifacts: "dist/*"
artifactContentType: application/gzip