From c5eca62912b5b5cd61dfdb6b10b13b1a694b9fc3 Mon Sep 17 00:00:00 2001 From: Joe Nudell Date: Thu, 9 Oct 2025 14:43:19 -0400 Subject: [PATCH 1/2] add release workflow --- .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..606b942 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Tag and release on version change + +on: + push: + branches: [ "main" ] + paths: + - "pyproject.toml" + +jobs: + tag: + name: Create tag if version updated + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write # Required for PyPI Trusted Publishing (OIDC) + steps: + - name: Checkout + uses: actions/checkout@v5 + + with: + fetch-depth: 0 + + - name: Setup uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Install Python 3.13 + run: uv python install 3.13 + + - name: Read version from pyproject.toml + id: version + run: | + python - <<'PY' >> "$GITHUB_OUTPUT" + import tomllib, pathlib + data = tomllib.loads(pathlib.Path('pyproject.toml').read_text(encoding='utf-8')) + version = data['project']['version'] + print(f"version={version}") + PY + + - name: Configure git user + run: | + git config user.name "github-actions[bot]" + git config user.email "action@github.com" + + - name: Create and push tag if missing + id: tag + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + set -euo pipefail + TAG="v${VERSION}" + echo "Version: ${VERSION}" + echo "Tag: ${TAG}" + git fetch --tags --force + # default output indicating whether we created a new tag in this run + echo "created=false" >> "$GITHUB_OUTPUT" + if git rev-parse "refs/tags/${TAG}" >/dev/null 2>&1; then + echo "Tag ${TAG} already exists. Skipping." + exit 0 + fi + git tag -a "${TAG}" -m "Release ${TAG}" + git push origin "${TAG}" + echo "created=true" >> "$GITHUB_OUTPUT" + + - name: Create GitHub Release + if: ${{ steps.tag.outputs.created == 'true' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.version.outputs.version }} + name: v${{ steps.version.outputs.version }} + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and publish distributions + if: ${{ steps.tag.outputs.created == 'true' }} + run: | + uv build + uv publish + From 03eaebd951d18951cb27f27727783bd67216bbb1 Mon Sep 17 00:00:00 2001 From: Joe Nudell Date: Thu, 9 Oct 2025 14:46:52 -0400 Subject: [PATCH 2/2] fix trailing spaces --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 606b942..14fe532 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,4 +78,3 @@ jobs: run: | uv build uv publish -