Skip to content

Commit aa795d1

Browse files
committed
ci: create stable Python releases
1 parent 716ead5 commit aa795d1

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
build:
1717
name: Build distributions
1818
runs-on: ubuntu-latest
19+
outputs:
20+
stable: ${{ steps.version.outputs.stable }}
1921
steps:
2022
- uses: actions/checkout@v7
2123

@@ -24,6 +26,7 @@ jobs:
2426
python-version: "3.11"
2527

2628
- name: Validate tag matches package version
29+
id: version
2730
env:
2831
RELEASE_TAG: ${{ github.ref_name }}
2932
run: |
@@ -33,6 +36,12 @@ jobs:
3336
exit 1
3437
fi
3538
39+
if [[ "$package_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
40+
echo "stable=true" >> "$GITHUB_OUTPUT"
41+
else
42+
echo "stable=false" >> "$GITHUB_OUTPUT"
43+
fi
44+
3645
- name: Install test and build tools
3746
run: |
3847
python -m pip install --upgrade -e .
@@ -77,3 +86,24 @@ jobs:
7786

7887
- name: Publish to PyPI
7988
uses: pypa/gh-action-pypi-publish@v1.14.0
89+
90+
release:
91+
name: Create stable GitHub Release
92+
if: needs.build.outputs.stable == 'true'
93+
needs: [build, publish]
94+
runs-on: ubuntu-latest
95+
permissions:
96+
contents: write
97+
98+
steps:
99+
- name: Create GitHub Release
100+
env:
101+
GH_TOKEN: ${{ github.token }}
102+
RELEASE_TAG: ${{ github.ref_name }}
103+
REPOSITORY: ${{ github.repository }}
104+
run: |
105+
if gh release view "$RELEASE_TAG" --repo "$REPOSITORY" >/dev/null 2>&1; then
106+
echo "GitHub Release $RELEASE_TAG already exists"
107+
else
108+
gh release create "$RELEASE_TAG" --repo "$REPOSITORY" --generate-notes --verify-tag
109+
fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ git tag -a vX.Y.Z -m "vX.Y.Z"
269269
git push origin vX.Y.Z
270270
```
271271

272-
The tag triggers a build, metadata validation, and publication to PyPI. PEP 440 prerelease versions are supported as long as the tag exactly matches the version in `pyproject.toml`.
272+
The tag triggers a build, metadata validation, and publication to PyPI. PEP 440 prerelease versions are supported as long as the tag exactly matches the version in `pyproject.toml`. After PyPI publication succeeds, stable `X.Y.Z` versions create a GitHub Release automatically; prerelease tags do not.
273273

274274
## License
275275

0 commit comments

Comments
 (0)