Version packages from git tags and publish with trusted publishing - #8
Merged
Merged
Conversation
All six workspace packages build with the setuptools backend and take their version from setuptools-scm, each pointing at the repository root so one tag versions them in lockstep. The setuptools floor is 77, the first release supporting the PEP 639 license expression that harp and harp-protocol already declare. No version file is written, so runtime lookups go through importlib.metadata. The release job no longer sets versions in the tree, commits back to master, or force-moves the release tag. It passes the release tag to setuptools-scm through SETUPTOOLS_SCM_PRETEND_VERSION, fails if any distribution falls back to 0.0.0, and publishes through PyPI trusted publishing in a pypi environment rather than a token secret. The docs job deploys from the tag and fetches full history for git-authors attribution. The workflow is renamed to harp.yml after the distribution it builds. pyright replaces ty in the dev group and in CI, in standard mode, with three ty suppressions in harp-protocol translated to pyright and three more dropped.
Follows the default branch rename. Pushes to the default branch trigger the workflow again; without this the branch filter matches nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch picks up the four packaging and release items left from the first review round, so that versions come from git tags rather than being written into files, and a release publishes without any commit back to the default branch.
uv stays the resolver, locker, workspace manager, and build frontend. Only the build backend changes.
Versioning from git tags
All six workspace packages now build with the setuptools backend and take their version from setuptools-scm. Each sub-package sets
rootto../../..so all of them resolve the same repository root, which means one tag versions the whole set in lockstep. A build of this branch reports0.1.dev286+g9a71d40c2for all six, replacing the previous static0.0.0,0.4.0, and0.1.0values that had drifted apart.No
version_fileis generated, so anything needing the version at runtime should read it throughimportlib.metadata.The setuptools floor is
>=77rather than the more usual>=64. Release 77 is the first with PEP 639 support, and bothharpandharp-protocolalready setlicenseto the SPDX expressionMIT, withlicense-filesdeclared on the umbrella. An older setuptools would not produce that metadata as declared. The built umbrella wheel carries metadata version 2.4, aLicense-ExpressionofMIT, andLICENSEunderdist-info/licenses/.Type checking
pyrightreplacestyin the dev group and in CI, keeping the same scope as before, which is the four package source trees with tests excluded, on Python 3.11.typeCheckingModeisstandard. Fifteen of the individual rule escalations used inaeon_apiare adopted alongside it and all pass with no source changes. Two escalations from that repo are left out.reportPrivateUsagereports 57 errors, because the payload, register, and device code deliberately reaches across private members within the package family, andreportUnnecessaryComparisonflags two intentional runtime guards against callers passingenum=Nonein defiance of the annotation. Two non-escalation settings are also left out,reportMissingImportsset tononeanduseLibraryCodeForTypesset tofalse, so that missing imports stay reported and inlined dependency types stay in use.Standard mode reports five errors on the tree as it stands, all at three sites that already carry
ty: ignorecomments. Those three becomepyright: ignore[reportArgumentType]. Three furtherty: ignorecomments are removed outright, since pyright accepts the expressions they covered.Release workflow
The
prepare-releasejob is gone, together with the version-setting loop, the commit back tomaster, and the force-move of the release tag. With the version coming from the tag there is nothing left to write back.build-releasereplaces it. The build passes the release tag to setuptools-scm throughSETUPTOOLS_SCM_PRETEND_VERSION, so the published version is the tag by construction rather than inferred from history and then validated. Tag spellings normalize on the way through, withv1.0.0-rc1arriving as1.0.0rc1, and the one variable covers all six packages. Nothing is written back to the tree, so this replaces the version rewriting rather than reinstating a lighter form of it.Checkout stays at its default depth, matching
aeon_api. Setting the version explicitly is what makes that unconditionally correct, instead of resting on the fact that a release event happens to check out a tag.One failure mode still warrants a check. Were a
pyproject.tomlto lose itstool.setuptools_scmtable, setuptools-scm would not engage, the variable would be ignored, and the build would fall back to0.0.0, a valid version that PyPI accepts without complaint. A single glob overdistcatches that.publish-to-pypiuses PyPI trusted publishing through apypienvironment instead of thePYPI_TOKENsecret. Declaringpermissionson a job replaces the default set rather than adding to it, so the job requestscontents: writealongsideid-token: write, the former being whataction-gh-releaseneeds to attach the distributions to the release.The docs job now deploys the tagged commit rather than
master, so a release publishes documentation matching the released code. It is also the one job that setsfetch-depthto0, because thegit-authorsplugin walks history to attribute pages and at the default depth of a single commit that attribution comes out empty.The workflow file is renamed from
pyharp.ymltoharp.ymland its name frompyharp test suitetoharp, matching the distribution it builds and the naming already applied elsewhere. Nothing referenced the old file name, and the job names are unchanged, so required status checks still match. The rename belongs with this change because a trusted publisher is bound to the workflow file name, and doing it now avoids configuring the five publishers twice.Verification
Run locally on Windows against Python 3.13. codespell,
ruff format --check,ruff check, andpyrightare clean, 166 tests pass, anduv build --all-packagesproduces all 12 artifacts. Every wheel carries itspy.typedwithout needing apackage-dataentry, becauseinclude-package-datadefaults to true under pyproject configuration and the setuptools-scm file finder picks up tracked files.twine checkpasses on all distributions. Driving the build the waybuild-releasedoes confirms both directions. Av0.5.0tag yields0.5.0for all six packages andv1.0.0-rc1yields1.0.0rc1, while removing atool.setuptools_scmtable falls back to0.0.0and trips the check.Before the first release
harp-tech, repositorypyharp, workflowharp.yml, environmentpypi. Three of the five need pending publishers, sinceharp,harp-device, andharp-datado not exist on PyPI yet.harp-protocolandharp-serialare already published and can be configured directly.0.5.0or higher, sinceharp-protocolandharp-serialare already published at 0.4.0.PYPI_TOKENsecret, once a release has published successfully.