-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (98 loc) · 2.86 KB
/
release.yml
File metadata and controls
119 lines (98 loc) · 2.86 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Release
on:
push:
tags:
- 'v*'
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
name: Build & Test
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python 3.13
run: uv python install 3.13
- name: Install dependencies
run: uv sync --dev
- name: Verify tag matches package version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match pyproject.toml version ${PKG_VERSION}"
exit 1
fi
echo "Version check passed: ${PKG_VERSION}"
- name: Run linter
run: uv run ruff check src/ tests/
- name: Run type checker
run: uv run pyright src/
- name: Run tests
run: uv run pytest --tb=short -q
- name: Build package
run: uv build
- name: Verify wheel contents
run: |
uv run python -c "
import zipfile, glob, sys
wheels = glob.glob('dist/*.whl')
if not wheels:
print('No wheel found')
sys.exit(1)
with zipfile.ZipFile(wheels[0]) as zf:
names = zf.namelist()
if not any('synonyms.yaml' in n for n in names):
print('synonyms.yaml not found in wheel')
sys.exit(1)
print('Wheel contents OK')
"
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
name: Publish to PyPI
timeout-minutes: 10
environment: pypi
permissions:
id-token: write
contents: read
attestations: write
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: 'dist/*'
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
needs: publish
runs-on: ubuntu-latest
name: Create GitHub Release
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true