-
Notifications
You must be signed in to change notification settings - Fork 133
85 lines (67 loc) · 2.04 KB
/
release.yml
File metadata and controls
85 lines (67 loc) · 2.04 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Release
on:
release:
types: [published]
jobs:
check-tag:
name: check tag matches pyproject version
runs-on: ubuntu-latest
steps:
- name: repository checkout step
uses: actions/checkout@v6
- name: python environment step
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: check version
shell: bash
run: |
TAG="${{ github.event.release.tag_name }}"
GH_TAG_NAME="${TAG#v}"
PY_VERSION=$(python - <<'PY'
import pathlib, tomllib
data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
print(data["project"]["version"])
PY
)
if [ "${GH_TAG_NAME}" != "${PY_VERSION}" ]; then
echo "::error::Tag (${GH_TAG_NAME}) does not match pyproject.toml version (${PY_VERSION})."
exit 1
fi
build-dist:
name: build sdist and wheel
runs-on: ubuntu-latest
needs: check-tag
steps:
- name: repository checkout step
uses: actions/checkout@v6
- name: python environment step
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: install build tools
run: |
python -m pip install --upgrade build twine
- name: build distributions
run: python -m build --sdist --wheel --outdir dist
- name: check distributions
run: python -m twine check dist/*
- name: upload distributions
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/*
publish-to-pypi:
name: publish to PyPI
runs-on: ubuntu-latest
needs: build-dist
permissions:
id-token: write
steps:
- name: download distributions
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist
- name: publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1