-
-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.2 KB
/
python-dist.yml
File metadata and controls
83 lines (71 loc) · 2.2 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
name: publish
on:
push:
tags:
- 'version-*'
permissions:
contents: read
jobs:
tests:
uses: ./.github/workflows/python_tests.yml
release-build:
runs-on: ubuntu-latest
# Build and publish are gated on successful tests.
needs:
- tests
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.14"
- name: Validate tag matches project version
shell: bash
run: |
tag="${GITHUB_REF_NAME}"
if [[ ! "$tag" =~ ^version-[0-9]+$ ]]; then
echo "Tag '$tag' does not match required pattern version-N"
exit 1
fi
project_version=$(python - <<'PY'
import pathlib, re
# pyproject.toml uses dynamic versioning; the canonical version is in __init__.py
content = pathlib.Path('src/structurefinder/__init__.py').read_text(encoding='utf-8')
m = re.search(r'^__version__\s*=\s*([0-9]+)', content, flags=re.MULTILINE)
if not m:
raise SystemExit('Could not find __version__ in src/structurefinder/__init__.py')
print(m.group(1))
PY
)
tag_version="${tag#version-}"
if [[ "$tag_version" != "$project_version" ]]; then
echo "Tag version '$tag_version' does not match pyproject version '$project_version'"
exit 1
fi
echo "Tag and project version are consistent: $project_version"
- run: |
uv sync --build
uv build
- uses: actions/upload-artifact@v7
with:
name: release-dists
path: dist/
pypi-publish:
needs:
- release-build
name: publish
runs-on: ubuntu-latest
environment:
name: publish
url: https://pypi.org/p/structurefinder
permissions:
contents: read
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v8
with:
name: release-dists
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/