From 4534263f1a2a4a85a426c1bb536c1dced5e6a8ed Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Sun, 8 Mar 2026 20:40:08 +0000 Subject: [PATCH] Complete towncrier migration for versioning workflow The Makefile, pyproject.toml, and bump_version.py were already migrated to towncrier, but the versioning workflow still triggered on changelog_entry.yaml and used yaml-changelog. This meant changelog.d/ fragments never triggered version bumps or PyPI publishes. - Trigger on changelog.d/** and pyproject.toml instead of changelog_entry.yaml - Use towncrier build instead of yaml-changelog - Read version from pyproject.toml instead of setup.py in publish-git-tag.sh - Remove duplicate towncrier dep, drop yaml-changelog Co-Authored-By: Claude --- .github/publish-git-tag.sh | 5 +++-- .github/workflows/versioning.yaml | 22 +++++++++++++--------- pyproject.toml | 3 +-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/publish-git-tag.sh b/.github/publish-git-tag.sh index 0143c67b0..8a2196d2f 100755 --- a/.github/publish-git-tag.sh +++ b/.github/publish-git-tag.sh @@ -1,4 +1,5 @@ #! /usr/bin/env bash -git tag `python setup.py --version` -git push --tags || true # update the repository version +VERSION=$(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))") +git tag "$VERSION" +git push --tags || true diff --git a/.github/workflows/versioning.yaml b/.github/workflows/versioning.yaml index 570140730..e08152889 100644 --- a/.github/workflows/versioning.yaml +++ b/.github/workflows/versioning.yaml @@ -7,29 +7,33 @@ on: - main paths: - - changelog_entry.yaml - - .github/** + - changelog.d/** + - pyproject.toml workflow_dispatch: jobs: Versioning: - if: (github.event.head_commit.message != 'Update package version') runs-on: ubuntu-latest + if: | + (!(github.event.head_commit.message == 'Update package version')) steps: - name: Checkout repo uses: actions/checkout@v4 with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.POLICYENGINE_GITHUB }} + fetch-depth: 0 + - name: Install uv + uses: astral-sh/setup-uv@v5 - name: Setup Python uses: actions/setup-python@v5 with: python-version: 3.12 - - name: Build changelog - run: pip install yaml-changelog && make changelog - - name: Preview changelog update - run: ".github/get-changelog-diff.sh" + - name: Install towncrier + run: uv pip install towncrier --system + - name: Bump version and build changelog + run: | + python .github/bump_version.py + towncrier build --yes --version $(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))") - name: Update changelog uses: EndBug/add-and-commit@v9 with: diff --git a/pyproject.toml b/pyproject.toml index 40ea0503c..a56a4d8df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,11 +63,10 @@ dev = [ "sphinx-argparse>=0.3.2,<1", "sphinx-math-dollar>=1.2.1,<2", "wheel", - "yaml-changelog>=0.1.7", + "towncrier>=24.8.0", "snowballstemmer>=2,<3", "jupyter-book>=2.0.0a0", "rich", - "towncrier>=24.8.0", ] [tool.pytest.ini_options]