Skip to content

Commit 43b5522

Browse files
authored
[MNT] updated release workflow (#626)
updates release workflow: * newer python versions * use of official actions for packaging
1 parent ff8351b commit 43b5522

1 file changed

Lines changed: 78 additions & 32 deletions

File tree

.github/workflows/releasing.yml

Lines changed: 78 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,81 @@ on:
55
types: [published]
66

77
jobs:
8-
# based on https://github.com/pypa/gh-action-pypi-publish
9-
release-pkg:
10-
runs-on: ubuntu-20.04
11-
timeout-minutes: 10
12-
steps:
13-
- name: Checkout 🛎️
14-
uses: actions/checkout@v6
15-
- name: Set up Python 🐍
16-
uses: actions/setup-python@v5
17-
with:
18-
python-version: 3.8
19-
20-
- name: Create package 📦
21-
run: |
22-
pip install "twine==5.1.1" setuptools wheel
23-
python setup.py sdist bdist_wheel
24-
ls -lh dist/
25-
twine check dist/*
26-
27-
- name: Upload to release
28-
if: github.event_name == 'release'
29-
uses: AButler/upload-release-assets@v3.0
30-
with:
31-
files: "dist/*"
32-
repo-token: ${{ secrets.GITHUB_TOKEN }}
33-
34-
- name: Publish distribution 📦 to PyPI
35-
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
36-
uses: pypa/gh-action-pypi-publish@v1.12.2
37-
with:
38-
user: __token__
39-
password: ${{ secrets.pypi_password }}
8+
check_tag:
9+
name: Check tag
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- uses: actions/setup-python@v6
16+
with:
17+
python-version: '3.11'
18+
19+
- shell: bash
20+
run: |
21+
TAG="${{ github.event.release.tag_name }}"
22+
GH_TAG_NAME="${TAG#v}"
23+
PY_VERSION=$(python - <<'PY'
24+
import pathlib, tomllib
25+
data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
26+
print(data.get("project").get("version"))
27+
PY
28+
)
29+
if [ "${GH_TAG_NAME}" != "${PY_VERSION}" ]; then
30+
echo "::error::Tag (${GH_TAG_NAME}) does not match pyproject.toml version (${PY_VERSION})."
31+
exit 2
32+
fi
33+
34+
build_wheels:
35+
needs: check_tag
36+
name: Build wheels
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v6
41+
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v7
44+
with:
45+
enable-cache: true
46+
47+
- uses: actions/setup-python@v6
48+
with:
49+
python-version: '3.10'
50+
51+
- name: Build wheel
52+
run: |
53+
uv pip install build
54+
uv build --wheel --sdist --out-dir wheelhouse
55+
env:
56+
UV_SYSTEM_PYTHON: 1
57+
58+
- name: Store wheels
59+
uses: actions/upload-artifact@v6
60+
with:
61+
name: wheels
62+
path: wheelhouse/*
63+
64+
# based on https://github.com/pypa/gh-action-pypi-publish
65+
release-pkg:
66+
runs-on: ubuntu-latest
67+
needs: [build_wheels]
68+
69+
permissions:
70+
id-token: write
71+
72+
timeout-minutes: 10
73+
steps:
74+
- uses: actions/download-artifact@v7
75+
with:
76+
name: wheels
77+
path: wheelhouse
78+
79+
- name: Publish distribution 📦 to PyPI
80+
uses: pypa/gh-action-pypi-publish@release/v1
81+
with:
82+
user: __token__
83+
password: ${{ secrets.pypi_password }}
84+
packages-dir: wheelhouse/
85+

0 commit comments

Comments
 (0)