-
Notifications
You must be signed in to change notification settings - Fork 154
654 lines (631 loc) · 27.1 KB
/
ci.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
name: ci
on:
push:
branches:
- 'main'
- '[0-9][0-9].0[39]'
tags:
- '[0-9][0-9].0[39].*'
pull_request:
types: [labeled, unlabeled, opened, synchronize, reopened]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
optimize-ci:
runs-on: ubuntu-latest
# NOTE: Job outputs are ALWAYS strings while context variables may have native types.
# When evaluating the output in the 'if' condition of other jobs, we need to compare it
# with a string literal like 'false', 'true'.
permissions:
contents: read
pull-requests: write
outputs:
skip: ${{ steps.check_skip.outputs.SKIP }}
steps:
- name: Debug action trigger
run: |
echo "github.action: ${{ github.action }}"
echo "github.run_id: ${{ github.run_id }}"
echo "github.actor: ${{ github.actor }}"
echo "github.job: ${{ github.job }}"
echo "github.head_ref: ${{ github.head_ref }}"
echo "github.ref: ${{ github.ref }}"
echo "github.ref_name: ${{ github.ref_name }}"
echo "github.ref_type: ${{ github.ref_type }}"
echo "github.event_name: ${{ github.event_name }}"
echo "github.event_path: ${{ github.event_path }}"
echo "github.event.action: ${{ github.event.action }}"
echo "merge_group:"
echo " github.event.merge_group.head_ref: ${{ github.event.merge_group.head_ref }}"
echo " github.event.merge_group.base_ref: ${{ github.event.merge_group.base_ref }}"
echo "pull_request:"
echo " github.event.number: ${{ github.event.number }}"
echo " github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}"
echo " github.event.pull_request.base.ref: ${{ github.event.pull_request.base.ref }}"
echo "push:"
echo " github.event.after: ${{ github.event.after }}"
echo " github.event.before: ${{ github.event.before }}"
echo " github.event.base_ref: ${{ github.event.base_ref }}"
echo " github.event.ref: ${{ github.event.ref }}"
echo "---"
echo "concurrency-group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
- name: Optimize CI
if: ${{ github.event_name == 'pull_request' }}
id: graphite-ci-action
uses: withgraphite/graphite-ci-action@main
with:
graphite_token: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN }}
- name: Check if should skip the CI
id: check_skip
run: |
if [ "${{ steps.graphite-ci-action.outputs.skip }}" == "true" ]; then
echo "SKIP=true" >> $GITHUB_OUTPUT
else
echo "SKIP=false" >> $GITHUB_OUTPUT
fi
- name: labeler
if: github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'syncrhonize'
uses: lablup/auto-labeler@main # actions/labeler, lablup/size-label-action, lablup/auto-label-in-issue
lint:
if: |
!(
contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
else
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Check out the revision with minimal required history
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.GIT_FETCH_DEPTH }}
lfs: false
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Set up remote cache backend (if applicable)
run: |
echo "PANTS_REMOTE_STORE_ADDRESS=${REMOTE_CACHE_BACKEND_ENDPOINT}" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_READ=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_WRITE=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_INSTANCE_NAME=main" >> $GITHUB_ENV
env:
REMOTE_CACHE_BACKEND_ENDPOINT: ${{ secrets.PANTS_REMOTE_CACHE_ENDPOINT_ARC }}
if: ${{ env.REMOTE_CACHE_BACKEND_ENDPOINT != '' }}
- name: Bootstrap Pants
uses: ./actions/init-pants
# See: github.com/pantsbuild/actions/tree/main/init-pants/
# ref) https://github.com/pantsbuild/example-python/blob/main/.github/workflows/pants.yaml#L30-L49
with:
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'true'
- name: Check BUILD files
run: pants tailor --check update-build-files --check '::'
- name: Lint
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
fi
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
[ -n "$GITHUB_BASE_REF" ] && BASE_REF_SHORT="${GITHUB_BASE_REF}" || BASE_REF_SHORT="main"
BASE_REF="origin/${BASE_REF_SHORT}"
git remote set-branches origin "$BASE_REF_SHORT"
BASE_COMMIT=$(git rev-list --first-parent --max-parents=0 --max-count=1 HEAD)
BASE_TIMESTAMP=$(git log --format=%ct "${BASE_COMMIT}")
git fetch --no-tags --shallow-since "${BASE_TIMESTAMP}" origin "${BASE_REF_SHORT}"
else
BASE_REF="HEAD~1"
fi
pants lint --changed-since=$BASE_REF --changed-dependents=transitive
- name: Upload pants log
uses: actions/upload-artifact@v4
with:
name: pants.lint.log
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.
check-alembic-migrations:
if: |
(
contains(github.event.pull_request.labels.*.name, 'require:db-migration')
|| (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
)
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
&& needs.optimize-ci.outputs.skip == 'false'
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Check out the revision
uses: actions/checkout@v4
with:
lfs: false
- name: Parse versions from config
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Check for multiple heads
run: python scripts/check-multiple-alembic-heads.py
typecheck:
if: |
!(
contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
needs: [optimize-ci]
runs-on: ubuntu-latest
steps:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
else
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Check out the revision with minimal required history
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.GIT_FETCH_DEPTH }}
lfs: false
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Set up remote cache backend (if applicable)
run: |
echo "PANTS_REMOTE_STORE_ADDRESS=${REMOTE_CACHE_BACKEND_ENDPOINT}" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_READ=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_WRITE=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_INSTANCE_NAME=main" >> $GITHUB_ENV
env:
REMOTE_CACHE_BACKEND_ENDPOINT: ${{ secrets.PANTS_REMOTE_CACHE_ENDPOINT_ARC }}
if: ${{ env.REMOTE_CACHE_BACKEND_ENDPOINT != '' }}
- name: Bootstrap Pants
uses: ./actions/init-pants
with:
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'true'
- name: Typecheck
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
[ -n "$GITHUB_BASE_REF" ] && BASE_REF_SHORT="${GITHUB_BASE_REF}" || BASE_REF_SHORT="main"
BASE_REF="origin/${BASE_REF_SHORT}"
git remote set-branches origin "$BASE_REF_SHORT"
BASE_COMMIT=$(git rev-list --first-parent --max-parents=0 --max-count=1 HEAD)
BASE_TIMESTAMP=$(git log --format=%ct "${BASE_COMMIT}")
git fetch --no-tags --shallow-since "${BASE_TIMESTAMP}" origin "${BASE_REF_SHORT}"
else
BASE_REF="HEAD~1"
fi
pants check --changed-since=$BASE_REF --changed-dependents=transitive
- name: Upload pants log
uses: actions/upload-artifact@v4
with:
name: pants.check.log
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.
test:
if: |
!(
contains(github.event.pull_request.labels.*.name, 'skip:ci')
|| needs.optimize-ci.outputs.skip == 'true'
)
&& !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name)
&& github.event.pull_request.merged == false
needs: [optimize-ci]
runs-on: [ubuntu-latest-8-cores]
steps:
- name: Calculate the fetch depth
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
echo "GIT_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
else
echo "GIT_FETCH_DEPTH=2" >> "${GITHUB_ENV}"
fi
- name: Check out the revision with minimal required history
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.GIT_FETCH_DEPTH }}
lfs: false
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Set up remote cache backend (if applicable)
run: |
echo "PANTS_REMOTE_STORE_ADDRESS=${REMOTE_CACHE_BACKEND_ENDPOINT}" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_READ=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_CACHE_WRITE=true" >> $GITHUB_ENV
echo "PANTS_REMOTE_INSTANCE_NAME=main" >> $GITHUB_ENV
env:
REMOTE_CACHE_BACKEND_ENDPOINT: ${{ secrets.PANTS_REMOTE_CACHE_ENDPOINT }}
if: ${{ env.REMOTE_CACHE_BACKEND_ENDPOINT != '' }}
- name: Bootstrap Pants
uses: ./actions/init-pants
with:
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'true'
- name: Test
timeout-minutes: 15
run: |
# configure redis sentinel cluster hostnames for testing
grep -q "127.0.0.1 node01" /etc/hosts || echo "127.0.0.1 node01" | sudo tee -a /etc/hosts
grep -q "127.0.0.1 node02" /etc/hosts || echo "127.0.0.1 node02" | sudo tee -a /etc/hosts
grep -q "127.0.0.1 node03" /etc/hosts || echo "127.0.0.1 node03" | sudo tee -a /etc/hosts
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
[ -n "$GITHUB_BASE_REF" ] && BASE_REF_SHORT="${GITHUB_BASE_REF}" || BASE_REF_SHORT="main"
BASE_REF="origin/${BASE_REF_SHORT}"
git remote set-branches origin "$BASE_REF_SHORT"
BASE_COMMIT=$(git rev-list --first-parent --max-parents=0 --max-count=1 HEAD)
BASE_TIMESTAMP=$(git log --format=%ct "${BASE_COMMIT}")
git fetch --no-tags --shallow-since "${BASE_TIMESTAMP}" origin "${BASE_REF_SHORT}"
else
BASE_REF="HEAD~1"
fi
pants test --changed-since=$BASE_REF --changed-dependents=transitive -- -v
- name: Upload pants log
uses: actions/upload-artifact@v4
with:
name: pants.test.log
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.
build-scies:
needs: [lint, typecheck, test, check-alembic-migrations]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
# ubuntu-latest: x86-64
# ubuntu-22.04-arm64: aarch64
# macos-12: intel
# macos-13: apple silicon
os: [ubuntu-latest, ubuntu-22.04-arm64, macos-13-xlarge, macos-12-large]
runs-on: ${{ matrix.os }}
steps:
- name: Check out the revision
uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin 'refs/tags/*:refs/tags/*' -f
- name: Git LFS Pull
run: git lfs pull
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(awk -F'["]' '/CPython==/ {print $2; exit}' pants.toml | sed 's/CPython==//')
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Install coreutils for macOS
if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install coreutils
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
cache: "pip"
- name: Bootstrap Pants
uses: pantsbuild/actions/init-pants@v8
with:
gha-cache-key: pants-cache-main-1-deploy-py${{ env.PROJECT_PYTHON_VERSION }}-${{ runner.os }}-${{ runner.arch }}
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'false'
- name: Build fat packages
run: |
pants --tag="scie" package '::'
# 'pants run' does not support parallelization
pants list --filter-tag-regex='checksum' '::' | xargs -n 1 pants run
- name: Clean up intermediate pex files
run: |
rm -rf dist/src.*/
- name: Upload scies
uses: actions/upload-artifact@v4
with:
name: scies-${{ matrix.os }}
path: dist/*
- name: Upload pants log
uses: actions/upload-artifact@v4
with:
name: pants-${{ matrix.os }}.build-scies.log
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.
build-wheels:
needs: [lint, typecheck, test, check-alembic-migrations]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Check out the revision
uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin 'refs/tags/*:refs/tags/*' -f
- name: Git LFS Pull
run: git lfs pull
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(awk -F'["]' '/CPython==/ {print $2; exit}' pants.toml | sed 's/CPython==//')
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
cache: "pip"
- name: Install local dependencies for packaging
run: |
pip install -U 'packaging>=21.3'
- name: Bootstrap Pants
uses: pantsbuild/actions/init-pants@v8
with:
gha-cache-key: pants-cache-main-1-deploy-py${{ env.PROJECT_PYTHON_VERSION }}-${{ runner.os }}-${{ runner.arch }}
named-caches-hash: ${{ hashFiles('python*.lock', 'tools/*.lock') }}
cache-lmdb-store: 'false'
- name: Build wheel packages
run: |
# Normalize the package version
PKGVER=$(python -c "import packaging.version,pathlib; print(str(packaging.version.Version(pathlib.Path('VERSION').read_text())))")
echo "PKGVER=$PKGVER" >> $GITHUB_ENV
# Build non-platform-specific wheels
pants --platform-specific-resources-target=linux_x86_64 --tag="wheel" --tag="-platform-specific" package '::'
# Build x86_64 wheels
MANYLINUX_PTAG=manylinux2014_x86_64
MACOS_PTAG=macosx_11_0_x86_64
pants --platform-specific-resources-target=linux_x86_64 --tag="wheel" --tag="+platform-specific" package '::'
for pkgname in "kernel_binary"; do
mv "dist/backend.ai_${pkgname}-${PKGVER}-py3-none-any.whl" \
"dist/backend.ai_${pkgname}-${PKGVER}-py3-none-${MANYLINUX_PTAG}.${MACOS_PTAG}.whl"
done
# Build arm64 wheels
MANYLINUX_PTAG=manylinux2014_aarch64
MACOS_PTAG=macosx_11_0_arm64
pants --platform-specific-resources-target=linux_arm64 --tag="wheel" --tag="+platform-specific" package '::'
for pkgname in "kernel_binary"; do
mv "dist/backend.ai_${pkgname}-${PKGVER}-py3-none-any.whl" \
"dist/backend.ai_${pkgname}-${PKGVER}-py3-none-${MANYLINUX_PTAG}.${MACOS_PTAG}.whl"
done
ls -lh dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*
- name: Upload pants log
uses: actions/upload-artifact@v4
with:
name: pants.build-wheels.log
path: .pants.d/workdir/pants.log
if: always() # We want the log even on failures.
build-sbom:
needs: [lint, typecheck, test, check-alembic-migrations]
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
uses: ./.github/workflows/sbom.yml
make-final-release:
needs: [build-scies, build-wheels, build-sbom]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
environment: deploy-to-pypi
steps:
- uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin 'refs/tags/*:refs/tags/*' -f
- name: Extract Python version from pants.toml
run: |
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python as Runtime
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
- name: Install towncrier requirements
run: |
pip install -U -r tools/towncrier-requirements.txt
- name: Install local dependencies for packaging
run: |
pip install -U 'twine~=5.0' 'packaging>=21.3'
- name: Extract the release changelog
run: |
python ./scripts/extract-release-changelog.py
python ./scripts/determine-release-type.py
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: wheels
path: dist
- name: Download scies
uses: actions/download-artifact@v4
with:
pattern: scies-*
path: dist
merge-multiple: true
- name: Download SBOM report
uses: actions/download-artifact@v4
with:
name: SBOM report
path: dist
- name: Release to GitHub
uses: softprops/action-gh-release@v2
with:
body_path: "CHANGELOG_RELEASE.md"
prerelease: ${{ env.IS_PRERELEASE }}
files: |
dist/*
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# We don't use `pants publish ::` because we manually rename the
# wheels after buildling them to add arch-specific tags.
run: |
twine upload dist/*.whl dist/*.tar.gz
- name: Extract stable release version
id: extract_stable_release_version
run: |
release_version=$(awk -F'.' '{print $1"."$2}' <<< "${{ github.ref_name }}")
echo "RELEASE_VERSION=$release_version" >> $GITHUB_OUTPUT
- name: Update stable installer shorten URL
if: ${{ env.IS_PRERELEASE == 'false' && vars.STABLE_RELEASE == steps.extract_stable_release_version.outputs.RELEASE_VERSION }}
run: |
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-stable-macos-aarch64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-macos-aarch64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-stable-macos-x86_64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-macos-x86_64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-stable-linux-aarch64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-linux-aarch64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-stable-linux-x86_64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-linux-x86_64"
}'
- name: Extract edge release version
id: extract_edge_release_version
run: |
release_version=$(git branch -r | grep -E 'origin/[0-9]{2}\.[0-9]{2}$' | awk -F'/' '{print $2}' | sort -V | tail -n 1)
echo "RELEASE_VERSION=$release_version" >> $GITHUB_OUTPUT
- name: Update edge installer shorten URL
if: ${{ startsWith(github.ref_name, steps.extract_edge_release_version.outputs.RELEASE_VERSION) }}
run: |
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-edge-macos-aarch64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-macos-aarch64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-edge-macos-x86_64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-macos-x86_64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-edge-linux-aarch64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-linux-aarch64"
}'
curl -X 'PATCH' \
'https://bnd.ai/rest/v3/short-urls/installer-edge-linux-x86_64' \
-H 'accept: application/json' \
-H 'X-Api-Key: ${{ secrets.SHLINK_TOKEN }}' \
-H 'Content-Type: application/json' \
-d '{
"longUrl": "https://github.com/lablup/backend.ai/releases/download/${{ github.ref_name }}/backendai-install-linux-x86_64"
}'
build-conda-pack-for-windows:
needs: [make-final-release]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Check out the revision
uses: actions/checkout@v4
- name: Git LFS Pull
run: git lfs pull
- name: Extract Python version from pants.toml
shell: bash
run: |
export LANG=C.UTF-8
PYTHON_VERSION=$(grep -m 1 -oP '(?<=CPython==)([^"]+)' pants.toml)
echo "PANTS_CONFIG_FILES=pants.ci.toml" >> $GITHUB_ENV
echo "PROJECT_PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PROJECT_PYTHON_VERSION }}
cache: pip
- name: Install local dependencies for packaging
run: |
pip install -U 'packaging>=21.3'
- name: Normalize the package version
shell: bash
run: |
PKGVER=$(python -c "import packaging.version,pathlib; print(str(packaging.version.Version(pathlib.Path('VERSION').read_text())))")
echo "PKGVER=$PKGVER" >> $GITHUB_ENV
- name: Install conda-pack
uses: s-weigand/setup-conda@v1
with:
activate-conda: false
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: wheels
path: dist
- name: Create conda environment
# FIXME: Let's think about resolving dependency of backend.ai-client package programmatically, instead of hardcoding it.
run: |
pip install conda-pack
conda create -n backend.ai-client python=${{ env.PROJECT_PYTHON_VERSION }}
conda activate backend.ai-client
pip install dist/backend.ai_client-${{ env.PKGVER }}-py3-none-any.whl dist/backend.ai_cli-${{ env.PKGVER }}-py3-none-any.whl dist/backend.ai_common-${{ env.PKGVER }}-py3-none-any.whl dist/backend.ai_plugin-${{ env.PKGVER }}-py3-none-any.whl
conda-pack -o backend.ai-client-${{ github.ref_name }}-windows-conda.zip
- name: Upload conda-pack to GitHub release
run: |
gh release upload ${{ github.ref_name }} backend.ai-client-${{ github.ref_name }}-windows-conda.zip
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}