-
-
Notifications
You must be signed in to change notification settings - Fork 337
61 lines (54 loc) · 2.06 KB
/
python-publish-gpu.yml
File metadata and controls
61 lines (54 loc) · 2.06 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
name: Build and publish GPU 🐍📦 to PyPI
on:
push:
tags:
- 'v*'
jobs:
test:
name: Test before publish
uses: ./.github/workflows/tests.yml
build-n-publish-gpu:
needs: test
if: startsWith(github.ref, 'refs/tags/')
name: Build and publish GPU 🐍📦 to PyPI
runs-on: ubuntu-latest
environment:
name: pypi-gpu
url: https://pypi.org/p/anylabeling-gpu
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python -m pip install build==1.2.2 twine==6.1.0 --user
- name: Set preferred device to GPU
run: >-
sed -i'' -e 's/\_\_preferred_device\_\_[ ]*=[ ]*\"[A-Za-z0-9]*\"/__preferred_device__ = "GPU"/g' anylabeling/app_info.py
# PEP 621 makes pyproject.toml `[project]` metadata authoritative — setup.py
# cannot override `name` or replace `dependencies`. Rewrite pyproject.toml
# in place so the GPU wheel ships as `anylabeling-gpu` with onnxruntime-gpu.
- name: Rewrite pyproject.toml for the GPU package
run: |
sed -i 's/^name = "anylabeling"$/name = "anylabeling-gpu"/' pyproject.toml
sed -i 's/"onnxruntime>=1.20.0"/"onnxruntime-gpu>=1.20.0"/' pyproject.toml
echo "--- after rewrite ---"
grep -E '^name|onnxruntime' pyproject.toml
- name: Build a binary wheel and a source tarball
run: >-
python -m build --wheel --outdir dist/ .
- name: Verify built wheel is anylabeling-gpu
run: |
ls dist/
whl=$(ls dist/anylabeling_gpu-*.whl)
python -m zipfile -e "$whl" /tmp/whl_extract/
grep -E '^Name:|^Requires-Dist: onnxruntime' /tmp/whl_extract/anylabeling_gpu-*.dist-info/METADATA
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true