Skip to content

Commit dd247fe

Browse files
authored
ci: add PyPI auto-publish workflow on tag push (#22)
ci: add PyPI auto-publish workflow on tag push. Refs devonartis/agentwrit#31
1 parent 81ce830 commit dd247fe

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
name: Build & Publish to PyPI
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: astral-sh/setup-uv@v4
20+
with:
21+
version: "latest"
22+
23+
- name: Build package
24+
run: uv build
25+
26+
- name: Verify package version matches tag
27+
if: startsWith(github.ref, 'refs/tags/v')
28+
run: |
29+
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
30+
PKG_VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
31+
if [ "${TAG_VERSION}" != "${PKG_VERSION}" ]; then
32+
echo "::error::Tag version (${TAG_VERSION}) does not match package version (${PKG_VERSION})"
33+
exit 1
34+
fi
35+
echo "Version verified: ${PKG_VERSION}"
36+
37+
- name: Publish to PyPI
38+
run: uv publish dist/*
39+
env:
40+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)