Repository navigation
Workflow python package release
What it does. Builds the sdist and wheel, runs twine check --strict, reads the version off the sdist's own name and refuses a
tag that disagrees, runs your verify-command, installs the wheel into a fresh virtual environment and runs your
smoke-command, writes the release notes; then publishes to PyPI (Trusted Publishing, PEP 740 attestations) and to the GitHub
release with a SHA256SUMS and build provenance. No secret anywhere.
Why it exists. Four repositories had written build, check, tag-against-version and PyPI publish by hand, four slightly different ways. The checks that matter are the ones that catch a release that does not match its tag, or a wheel that does not install.
| Job | Holds | Notes |
|---|---|---|
build |
contents: read |
Everything that runs your code: the build, twine check, verify-command, the wheel smoke test, the release notes command |
publish-pypi |
id-token: write |
Checks nothing out. Hands dist/ to PyPI over the job's OIDC identity from the pypi environment |
github-release |
contents: write, id-token: write, attestations: write
|
Checks nothing out. Records provenance for every file and attaches them with a SHA256SUMS; creates the release from the notes or uploads to one that exists |
SBOMs. The build job also runs syft (pinned by version and sha256, the syft-version
and syft-sha256 inputs) over the unpacked wheel and sdist and writes sbom.cdx.json (CycloneDX) and sbom.spdx.json (SPDX). They
are their own artifact, so PyPI never receives them; github-release adds them to the release, to SHA256SUMS and to the same
provenance step. sbom: true is the default, and a pull request writes them too, so a broken SBOM is a red check, not a surprise at
tag time. They list the package and its metadata, not a resolved dependency tree. artifact-release.yml does not write them: its
files are arbitrary (a .deb, a firmware blob) and syft would report nothing, which reads as assurance and is not.
A pull request builds and checks and never publishes, whatever publish says. The version is read off the sdist's own name, so a
static version =, a dynamic attribute and a VCS plugin all answer alike.
on:
push: { tags: ['v*'] }
pull_request: # builds and checks; never publishes
workflow_dispatch:
jobs:
package:
uses: ChiefGyk3D/git-your-ship-together/.github/workflows/python-package-release.yml@<sha> # vX.Y.Z
permissions:
contents: write # the GitHub release and its assets
id-token: write # PyPI Trusted Publishing, and build provenance
attestations: write # the provenance record
with:
publish: ${{ startsWith(github.ref, 'refs/tags/v') }}
verify-command: grep -q "^## \[$VERSION\]" CHANGELOG.md
smoke-command: my-cli --version
egress-policy: blockPyPI setup, once per project. On the project's Publishing page add a Trusted Publisher naming this owner, the calling
repository, the caller's workflow file name (not this one's) and the environment pypi. That is the whole credential.
The workflow outputs version. SBOMs are not attached yet; see issue #99 on Releases and supply chain.
Inputs (21), read from python-package-release.yml:
| Input | Type | Default | Meaning |
|---|---|---|---|
python-version |
string | 3.13 |
Python used to build, check and smoke-test the package. |
package-directory |
string | . |
Directory holding pyproject.toml, relative to the repository root. |
build-install-command |
string | python -m pip install --upgrade pip build twine |
Shell that installs the build tooling. |
build-command |
string | python -m build |
Shell that writes the sdist and wheel to dist/. |
tag-prefix |
string | v |
What precedes the version in a release tag; v makes v1.2.3 the tag for version 1.2.3. |
verify-command |
string | empty | Shell run after the build with $VERSION set, to refuse a release whose tree disagrees with it, e.g. grep -q "^## \[$VERSION\]" CHANGELOG.md; empty runs nothing. |
smoke-command |
string | empty | Shell run with the built wheel installed in a fresh venv on PATH and $VERSION set, e.g. my-cli --version; empty skips the check. |
release-notes-command |
string | empty | Shell that prints the GitHub release notes to stdout with $VERSION set, e.g. a CHANGELOG section; empty lets GitHub generate them from the commits. |
publish |
boolean | false |
Publish to PyPI and the GitHub release. False builds, checks and stops; a pull request never publishes whatever this says. |
pypi |
boolean | true |
Publish to PyPI (Trusted Publishing; the project must name this workflow and the environment as a publisher). |
pypi-environment |
string | pypi |
The GitHub environment the PyPI job runs in, which is what the Trusted Publisher names. |
github-release |
boolean | true |
Attach the distribution files, their SBOMs, their SHA256SUMS and build provenance to the GitHub release for the tag. |
release-title |
string | empty | Title of a GitHub release this workflow creates; empty uses the tag. |
sbom |
boolean | true |
Write a CycloneDX and an SPDX SBOM for the built wheel and sdist (syft, pinned) and attach them to the GitHub release with the rest, listed in SHA256SUMS and covered by the same build provenance. They are written whenever the package is built, so a pull request exercises them; they are only published with the release. |
syft-version |
string | 1.54.0 |
syft release to download (anchore/syft), without the v; the one syft pin in this repository. Changing it means changing syft-sha256. To bump - gh release download v<new> -R anchore/syft -p '*_linux_amd64.tar.gz', sha256sum it and compare the line in the release's own *_checksums.txt. |
syft-sha256 |
string | 54a87372498168b2d033e876fd41fa4e8035b872699e525a57046e1f2f09c860 |
SHA-256 of the syft linux_amd64 tarball for that version. |
attest |
boolean | true |
Record SLSA build provenance for every distribution file through GitHub's attestation API. |
egress-policy |
string | audit |
harden-runner egress policy for every job - audit logs outbound connections, block allows only allowed-endpoints. |
allowed-endpoints |
string | api.github.com:443 files.pythonhosted.org:443 fulcio.sigstore.dev:443 github.com:443 pypi.org:443 rekor.sigstore.dev:443 release-assets.githubusercontent.com:443 timestamp.sigstore.dev:443 tuf-repo-cdn.sigstore.dev:443 upload.pypi.org:443 uploads.github.com:443 |
harden-runner allow-list for block, space-separated host:port entries. The build hosts were measured by running the build in block mode here; the publishing hosts are PyPI's and Sigstore's documented ones. Wildcards are not supported and a newline-separated list matches nothing. |
extra-allowed-endpoints |
string | empty | Appended to allowed-endpoints, for hosts only this repository reaches. Same format. |
timeout-minutes |
number | 20 |
Per-job timeout. |
Outputs a caller job can read:
| Output | Meaning |
|---|---|
version |
The version the sdist was built as. |
It never publishes from a pull request, never publishes a tag that disagrees with the packaged version, and never needs a stored credential.
Generated from docs/wiki/ at commit f3af2fa0bae3. Do not edit this wiki: the next push to main replaces every page. Corrections go to docs/wiki/ by pull request.
GYST
- Home
- Why GYST exists
- Getting started
- Design rules
- Secrets: Doppler and OIDC
- Security scanning explained
- The baseline and the weekly audit
- Releases and supply chain
- Keeping a project board current
- Adopting GYST in your own project
- Glossary
- Roadmap
Learn and contribute
- Learning path
- Which workflow do I need?
- Repository map
- Egress control
- Troubleshooting
- Lessons learned
- Testing and the contract
- Contributing and developing
- Maintaining this wiki
- Verify main
- FAQ
CI
Security
Release
- container-release
- python-docker-release
- python-package-release
- artifact-release
- verify-published
- base-image-digest
Docs and project
- docs-pages
- wiki-publish
- project-sync
- threat-model
- lory-audit
- agent-scan
- token-drift
- node-typecheck
- pr-title-lint
- vendored-drift
- upstream-sync
- repin
- pin-comments
Tools