Repository navigation
80 lines (68 loc) · 2.47 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (68 loc) · 2.47 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
name: Release
# Triggered when a version tag is pushed, e.g.:
# git tag v0.3.2.9 && git push origin v0.3.2.9
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
# 1. Build the sdist + wheel and verify the tag matches pyproject version.
# Tests run on the pull request (ci.yaml), so a tag only builds and releases.
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
- name: Verify tag matches pyproject version
run: |
TAG="${GITHUB_REF_NAME#v}"
PKG=$(uv version --short 2>/dev/null || python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
echo "Tag version: $TAG"
echo "Package version: $PKG"
if [ "$TAG" != "$PKG" ]; then
echo "::error::Tag ($TAG) does not match pyproject.toml version ($PKG) at $(git rev-parse --short HEAD). Push the version bump first, then move the tag: git push origin :refs/tags/$GITHUB_REF_NAME && git tag -f $GITHUB_REF_NAME <bump-commit> && git push origin $GITHUB_REF_NAME"
exit 1
fi
- name: Build sdist and wheel
run: uv build
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
# 2. Create the GitHub Release with auto-generated notes and attach artifacts.
# PyPI publishing is handled manually (see Makefile: `make publish`).
github-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # required to create a release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
# RELEASE_NOTES.md is the release text; GitHub appends the merged-PR list below it.
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: RELEASE_NOTES.md
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, 'rc') }}
files: dist/*
fail_on_unmatched_files: true