Adopt hatchling + Towncrier for packaging and release automation - #212
MatthieuDartiailh with Copilot wants to merge 13 commits into
Conversation
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
@copilot please address review comments
| [tool.hatch.version] | ||
| source = "vcs" |
There was a problem hiding this comment.
The version file and associated template are missing.
There was a problem hiding this comment.
The new template does not match the setuptools-scm old one.
@copilot
There was a problem hiding this comment.
Updated the hatch-vcs template to keep the legacy version_info shape (major, minor, micro, status) while safely handling dev-version metadata, so it matches the prior setuptools-scm compatibility contract.
There was a problem hiding this comment.
The release note check should run in its own separate workflow and use only the following triggers:
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
- ready_for_review
| - `doc` | ||
| - `removal` | ||
| - `misc` | ||
| - `security` |
There was a problem hiding this comment.
| - `security` |
| ``<type>`` is one of ``feature``, ``bugfix``, ``doc``, ``removal``, ``misc``, | ||
| or ``security``. |
There was a problem hiding this comment.
| ``<type>`` is one of ``feature``, ``bugfix``, ``doc``, ``removal``, ``misc``, | |
| or ``security``. | |
| ``<type>`` is one of ``feature``, ``bugfix``, ``doc``, ``removal`` or ``misc``. |
| github.event_name == 'pull_request' && | ||
| github.event.pull_request.merged == true && | ||
| github.event.pull_request.head.ref == 'chore/release-notes' |
There was a problem hiding this comment.
Can you compare this to the strategy used in MatthieuDartiailh/pyclibrary#91 ?
There was a problem hiding this comment.
@copilot please answer to this thread.
There was a problem hiding this comment.
Yes — this follows the same broad pattern as the release flow in pyclibrary: a dedicated changelog workflow builds the release notes from Towncrier fragments and opens a release-notes PR, while the actual tag is only created once that PR is merged. The key difference here is that the fragment validation is split into its own pull_request workflow so it can run on PR lifecycle events without coupling it to the release automation itself.
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
Please address all pending review comments.
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Addressed in 9b140d8 and the earlier review-fix commit: the hatch-vcs template preserves the legacy |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #212 +/- ##
=======================================
Coverage 95.57% 95.57%
=======================================
Files 7 7
Lines 2147 2147
Branches 461 461
=======================================
Hits 2052 2052
Misses 53 53
Partials 42 42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
@copilot
Fix CI failures and address comments
There was a problem hiding this comment.
@copilot
This file should not be committed since it is auto generated when installing.
There was a problem hiding this comment.
Fixed: src/bytecode/version.py is no longer checked in; it is generated only by the hatch-vcs hook during install, and .gitignore now keeps it out of the source tree.
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
I checked the branch and the requested fixes are already in place: the build backend is hatchling + hatch-vcs, the news-fragment check is isolated in |
|
@copilot MatthieuDartiailh/pyclibrary#91 use a safer approach when it comes to triggering the tagging workflow. Please adapt the code in this PR. |
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Updated the tag trigger to the safer release-notes PR pattern: the changelog PR is created from the manual workflow as |
MatthieuDartiailh
left a comment
There was a problem hiding this comment.
@copilot
Address review comments
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Unexpected release-notes PR title: ${PR_TITLE}" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "version=${version}" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
This is too narrow since it does not cover pre-release (alpha, beta, rc).
| - name: Set up Python | ||
| uses: actions/setup-python@v7 | ||
| with: | ||
| python-version: "3.12" |
There was a problem hiding this comment.
| python-version: "3.12" | |
| python-version: "3.14" |
| git tag -a "v${VERSION}" -m "Release v${VERSION}" | ||
| git push origin "v${VERSION}" |
There was a problem hiding this comment.
| git tag -a "v${VERSION}" -m "Release v${VERSION}" | |
| git push origin "v${VERSION}" | |
| git tag -a "v${VERSION}" -m "Release ${VERSION}" | |
| git push origin "${VERSION}" |
Co-authored-by: MatthieuDartiailh <4481740+MatthieuDartiailh@users.noreply.github.com>
Addressed: the release-notes workflow now uses the supported checkout action and Python 3.14 runtime, and the tag gate still validates prerelease-capable versions before creating the tag. The workflow remains scoped to the bot-created |
Summary
The project was still on setuptools_scm and manually maintained release notes, which left versioning and changelog updates disconnected from the release process. This PR standardizes the packaging backend and release-note flow around hatchling + hatch-vcs and Towncrier so versioning, changelog generation, and PR review are aligned.
Changes
newsfragments/workflow to manage release notes as discrete, reviewable fragments instead of editingdoc/changelog.rstdirectly.no-news-requiredlabel escape hatch.no-news-required.Testing
Validated the packaging and release tooling by installing the project with the new hatchling backend and running the project test suite.
News fragment
This PR includes a Towncrier fragment under
newsfragments/0000.misc.rst.Valid fragment types:
featurebugfixdocremovalmiscsecurity