From 45287be12567b809e317317221b2f50e7847dab1 Mon Sep 17 00:00:00 2001 From: Richard Abrich Date: Tue, 3 Mar 2026 22:50:23 -0500 Subject: [PATCH] ci: switch to python-semantic-release for automated versioning Conventional commit PR titles (feat:, fix:, etc.) auto-bump version, tag, publish to PyPI, and create GitHub Releases on merge to main. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/publish.yml | 58 ++++++++++++++++++++++++++++++----- pyproject.toml | 13 ++++++++ 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7cf12b6..8c24342 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,18 +1,60 @@ -name: Publish to PyPI +name: Release and PyPI Publish on: push: - tags: - - "v*" + branches: + - main jobs: - publish: + release: runs-on: ubuntu-latest environment: release + concurrency: release permissions: id-token: write + contents: write + steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v4 - - run: uv build - - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.ADMIN_TOKEN }} + + - name: Check if should skip + id: check_skip + run: | + if [ "$(git log -1 --pretty=format:'%an')" = "semantic-release" ]; then + echo "skip=true" >> $GITHUB_OUTPUT + fi + + - name: Set up Python + if: steps.check_skip.outputs.skip != 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install uv + if: steps.check_skip.outputs.skip != 'true' + uses: astral-sh/setup-uv@v4 + + - name: Python Semantic Release + if: steps.check_skip.outputs.skip != 'true' + id: release + uses: python-semantic-release/python-semantic-release@v9.15.2 + with: + github_token: ${{ secrets.ADMIN_TOKEN }} + + - name: Build package + if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true' + run: uv build + + - name: Publish to PyPI + if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Publish to GitHub Releases + if: steps.check_skip.outputs.skip != 'true' && steps.release.outputs.released == 'true' + uses: python-semantic-release/publish-action@v9.15.2 + with: + github_token: ${{ secrets.ADMIN_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 371cc7c..d023088 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,3 +45,16 @@ packages = ["openadapt_types"] [tool.pytest.ini_options] testpaths = ["tests"] + +[tool.semantic_release] +version_toml = ["pyproject.toml:project.version"] +commit_message = "chore: release {version}" +major_on_zero = false + +[tool.semantic_release.branches.main] +match = "main" + +[tool.semantic_release.commit_parser_options] +allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"] +minor_tags = ["feat"] +patch_tags = ["fix", "perf"]