Releasing¶
BLUF: A release is a merge to main; a development build is a merge to develop. A merge to main creates
the tag and a public GitHub release straight away. Uploading to PyPI, TestPyPI or GHCR happens only when its
repository variable is true, and it waits for a person only if you gave that environment required reviewers. The
two TestPyPI upload jobs have run for real; the PyPI, SDK-on-PyPI and image jobs have not, so nothing is on PyPI or GHCR yet.
Publishing is driven by the branch a commit lands on, and a person approves every upload.
| Merge to | What happens | Where it goes |
|---|---|---|
develop |
a development build, <version>.dev<run number> |
TestPyPI |
main |
a release: the guard, the full tests, a tag and GitHub release, then the upload | PyPI |
Nothing uploads until you turn each index on with a repository variable and approve its environments,
so merging is safe before that setup is done. ADR 0009 records why the release moved from a pushed tag
to a merge to main.
Two keys¶
Daniel: If merging to main publishes to PyPI, one slip and a bad version is on the internet forever.
Professor Feynman: How does a bank vault open?
Daniel: Two keys, held by two people.
Professor Feynman: Here the first key is the merge, which asks. The second is a switch you set per index, such as
PUBLISH_TO_PYPI, plus a person approving the environment that uploads, if you set reviewers on it. Both are off by default. The tag and the GitHub release are not behind either key. A release also has a guard that refuses a version with no changelog section or leftover fragments.Daniel: And if the guard passes and I still publish something wrong?
Professor Feynman: Then you learn the hard part: PyPI never lets a version be reused. You cannot take it back, you release the next version. That is why you publish a pre-release first. The picture has one more limit: the second key is only as good as the person turning it, so read what you approve.
Daniel: Merge asks, the switch and the approval decide, and a mistake costs a version number. I will start with a pre-release.
Cutting a release¶
- On
develop, set__version__to the same new value insrc/engineering_influence/__init__.pyandpackages/engineering-influence-sdk/src/engineering_influence_sdk/__init__.py. Nothing else repeats the version:pyproject.toml,ei --versionand the API all read it. It must be a plain release version such as0.1.0or0.1.0a2, never a.devone. - Fold the changelog fragments into the new version's section and delete them:
uv run python scripts/fold_changelog.py <version>. It turns everychangelog.d/*.mdinto a bullet under a new## <version>heading (keeping a fresh empty## Unreleasedabove it). Update the status text that names the current alpha (README.md,llms.txt,docs/GETTING_STARTED.md) in the same commit.developdoes not claim a version until its release commit. - Merge
developintomainthrough a pull request. That merge is the release. The workflow starts by itself, the guard checks the version and the changelog, and thepypienvironment waits for a reviewer.
A merge to main that does not carry a new version fails loudly: the guard refuses it if the changelog
has no section for the version or unfolded fragments remain, and PyPI refuses a version it already has.
main should receive releases only.
To run the pipeline again for the current tip of develop or main, for example after approving a
failed upload, start it by hand: gh workflow run release.yml --ref main (or --ref develop). Any other
branch is refused.
What the pipeline does¶
| Job | Runs on | Does | Stops if |
|---|---|---|---|
guard |
both | Reads the branch. On main, checks the version against the changelog |
the ref is not develop or main; core and SDK versions differ; the version is not a plain release version; on main: no changelog section for exactly this version, unfolded fragments remain in changelog.d/, or the commit is not on main |
build |
both | Builds both packages, installs the real artifacts in clean environments, writes SHA256SUMS and a CycloneDX SBOM. On main it also runs the whole test suite. On develop the packages are built from a copy of the commit with the version stamped as <version>.dev<run number> and checked to install and report that version |
any test, twine check --strict, or an install check fails |
github-release |
main |
Attests the build provenance, then creates the tag v<version> at the built commit and a GitHub release with the artifacts, a checksum file and the SBOM. A repeat run finds the release and leaves it |
it cannot create the release; a tag v<version> already exists and points at a different commit; GitHub gives any answer about the tag other than a clear "not found" |
testpypi |
develop |
Uploads the core package to TestPyPI | PUBLISH_TO_TESTPYPI is not true (the job is skipped), or the testpypi environment is not approved |
testpypi-sdk |
develop |
Uploads the SDK, after the core | the core upload did not succeed, or the testpypi-sdk environment is not approved |
pypi |
main |
Uploads the core package to PyPI with attestations, after the GitHub release | PUBLISH_TO_PYPI is not true (the job is skipped), or the pypi environment is not approved |
pypi-sdk |
main |
Uploads the SDK to PyPI with attestations, after the core | the core was not published, or the pypi-sdk environment is not approved |
images |
main |
Builds the runtime and worker-tex images from the released commit, runs ei --version in each, pushes them to GHCR and attests the provenance of each by digest, after the GitHub release |
PUBLISH_IMAGES is not true (the job is skipped), or the ghcr environment is not approved; an image reports another version; a tag is already published from a different commit, or the registry gives any answer about it other than a clear "no such manifest" |
The build job is the same reusable workflow that CI runs on every push (distribution). A release
therefore cannot fail on packaging for the first time at release time. Versions with a, b or rc are
marked as pre-releases.
Builds are reproducible: with the commit's timestamp fixed as SOURCE_DATE_EPOCH, two builds of the same
commit give byte-identical files.
Tags¶
The workflow creates the tag v<version> itself, at the commit it built. Before it does, it looks the tag
up. A tag that does not exist is created. A tag that exists must point at the built commit (an annotated
tag is followed to the commit it names), or nothing is released and the run fails with both commits in
the message. That matters because anyone with write access can push a tag, and gh release create ignores
its target when the tag exists, which would attach these files to a different commit. If GitHub answers
the lookup with anything other than a clear "not found", the release also stops.
If that happens, find out who made the tag and why, delete it if it is wrong, and run the workflow again.
Do not tag by hand. In the repository settings, a tag ruleset for v* that only the release workflow
can create would close this for good; that is a setting, and this repository does not change it for you.
Development builds¶
A package index never accepts a version twice, and develop carries one version until the next release,
so each merge to develop is uploaded as <version>.dev<run number>, for example 0.1.0a2.dev57. The
number is the workflow's run number, which only goes up, and a re-run of the same run keeps its number
(skip-existing lets it pass over files TestPyPI already has). The build is made from a copy of the
commit, so the checkout, uv.lock and the tests all see the real version.
Runs for one branch queue behind each other. If several merges land while one run is waiting for an
approval, GitHub keeps only the newest queued run and drops the older ones, so a development build can
be skipped. That is harmless for develop, where the latest build is the one that matters. For main,
merge one release at a time.
A development version sorts before the release it is named for. If develop still carries the version
of a release that is already on PyPI, its development builds sort below that release; bump the version
in develop right after a release if that matters.
One package, one environment¶
The core and the SDK are separate projects, each uploaded by its own job from its own GitHub environment. That is deliberate. A pending trusted publisher is told apart by its owner, repository, workflow and environment, so two pending publishers cannot share all four. The workflow file is the same for both, and the environment is what differs:
| Project | Workflow | On pypi.org | On test.pypi.org |
|---|---|---|---|
engineering-influence |
release.yml |
environment pypi |
environment testpypi |
engineering-influence-sdk |
release.yml |
environment pypi-sdk |
environment testpypi-sdk |
The core goes first and the SDK waits for it. The two are uploaded one after the other, not as one step, so a failure between them can leave the core published and the SDK not. A PyPI version can never be reused, so that is repaired by releasing the next version, not by uploading again.
One-time setup for TestPyPI¶
Every merge to develop uploads a development build once this is done. Do it once, before setting
PUBLISH_TO_TESTPYPI:
- On test.pypi.org, add a pending trusted publisher for each project, using the table above:
owner
adammatthewsteinberger, repositoryengineering-influence, workflowrelease.yml. - In the repository settings, create the environments
testpypiandtestpypi-sdk. A workflow that names an environment that does not exist creates it with no protection, so create them first. Required reviewers on these two mean every merge todevelopwaits for an approval; leave them off if you want development builds to upload on their own. Limiting each environment's deployment branches todevelopis a good addition. - Set the repository variable
PUBLISH_TO_TESTPYPItotrue.
One-time setup for PyPI¶
Do this once per repository, before setting the variable:
- On PyPI, add a pending trusted publisher for each project, using the table above:
owner
adammatthewsteinberger, repositoryengineering-influence, workflowrelease.yml. - In the repository settings, create the environments
pypiandpypi-sdk, add required reviewers to both so a person approves every PyPI upload, and limit their deployment branches tomain. - Set the repository variable
PUBLISH_TO_PYPItotrue.
A PyPI version can never be replaced or reused. Publish a pre-release first.
The images¶
A release also publishes two images to ghcr.io/adammatthewsteinberger/engineering-influence:
| Tag | Image | Moves |
|---|---|---|
<version> |
the slim runtime target (API and worker) |
never: a tag built from another commit stops the job |
<version>-tex |
the worker-tex target (the worker that can build books) |
never |
latest, tex |
the same two images | on a stable release only; a pre-release (a, b, rc) leaves them alone |
Each image is checked before it is pushed: ei --version in it must print the released version. Each one carries the
OCI labels source, revision (the commit) and version, and a build-provenance attestation stored in the registry
beside it. A repeat run finds a version tag already published from the same commit and leaves it alone, and refuses one
published from another.
One-time setup, before setting the variable:
- In the repository settings, create the environment
ghcr, add required reviewers, and limit its deployment branches tomain. A workflow that names an environment that does not exist creates it with no protection. - Set the repository variable
PUBLISH_IMAGEStotrue. - After the first push, open the package on GitHub and set its visibility. A new package starts private, and a private image cannot be pulled by the people who read this documentation.
The workflow logs in with the run's own token, so no secret is stored. Not yet verified: the job has never run, so the
build time (the TeX image is about 2.9 GB) and whether a hosted runner has the disk for both images are unknown, and the
base image python:3.13-slim is a tag, not a digest, so two builds of one commit can differ.
Checking a download¶
sha256sum -c SHA256SUMS
gh attestation verify engineering_influence-1.0.0-py3-none-any.whl --repo adammatthewsteinberger/engineering-influence
gh attestation verify oci://ghcr.io/adammatthewsteinberger/engineering-influence:1.0.0 --repo adammatthewsteinberger/engineering-influence
Keeping the pipeline current¶
Every action in the workflows is pinned to a full commit SHA, with the version in a comment.
Dependabot proposes updates weekly and waits seven days after a release before offering it.
CI runs actionlint and zizmor (medium severity and above) on every workflow.
What has not been exercised¶
- Three of the five upload jobs have never run against a real index or registry:
pypi,pypi-sdkandimages. They need the trusted publishers, the environments and the variables described above.testpypiandtestpypi-sdkhave uploaded development builds. - The
github-releasejob has not run in its new form, which creates the tag itself instead of reading one. - The guard is tested against its own script (
tests/e2e/test_release_guard.py), and the development-build staging step against the real step (tests/e2e/test_dev_build_stage.py). The upload jobs are tested only by their shape. zizmorreports two low-severity suggestions to write./.github/workflows/…as$/…. The documented./form is kept deliberately.- No container image has been published yet: the
imagesjob has never run, and stays off untilPUBLISH_IMAGESistrueand theghcrenvironment is approved.