-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (73 loc) · 2.22 KB
/
Copy pathpublish.yml
File metadata and controls
89 lines (73 loc) · 2.22 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
86
87
88
89
name: Publish to PyPI
on:
release:
types:
- published
permissions:
contents: read
jobs:
build:
name: Build and validate distributions
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: pip
- name: Install build tools
run: python -m pip install --upgrade pip build twine
- name: Check release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<'PY'
import os
import pathlib
import tomllib
project = tomllib.loads(
pathlib.Path("pyproject.toml").read_text(encoding="utf-8")
)
package_version = project["project"]["version"]
release_version = os.environ["RELEASE_TAG"].removeprefix("v")
if package_version != release_version:
raise SystemExit(
f"Release tag {release_version!r} does not match "
f"package version {package_version!r}"
)
PY
- name: Build distributions
run: python -m build
- name: Validate distributions
run: python -m twine check dist/*
- name: Smoke-test wheel
run: |
python -m venv /tmp/jamkit-smoke
/tmp/jamkit-smoke/bin/python -m pip install dist/*.whl
/tmp/jamkit-smoke/bin/python -c \
"from jamkit.hack_the_robot.loader import load_workshop"
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-distributions
path: dist/
if-no-files-found: error
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/jamkit/
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-distributions
path: dist/
- name: Publish distributions
uses: pypa/gh-action-pypi-publish@release/v1