Skip to main content

Nicks Opinionated (Python Package) Publishing Tool

nopt checks Python release eligibility, builds a verified release bundle and optionally publishes a GitHub release. GitHub Actions handles CI, approvals and artifact storage; the PyPA publishing action uploads distributions to PyPI or TestPyPI.

This initial implementation requires Python 3.11+ and a Python project in a Git checkout. Any PEP 517 build backend supported by python-build can be used. It supports one wheel plus one source distribution. There is no PyPI upload command.

Install

Run the published package with uv (Python 3.11 or later):

uvx --from 'nopt==0.2.0' nopt --help

The workflow template uses the same pinned PyPI version in every job. When upgrading nopt, update all four command pins together and review the pinned action references before enabling production publishing.

For repeated local use, install it with uv tool install 'nopt==0.2.0', then run nopt directly.

Configure a project

Declare a static project name and version. This example shows the settings and their defaults. testpypi-username has no default and is required when the target is TestPyPI:

[project]
name = "example-package"
version = "1.2.3.dev4"

[tool.nopt]
changelog = "docs/changelog.md" # false disables extraction and date/content checks
repository = "pypi" # or "testpypi"
allow-dirty = ["dev"] # [] forbids all dirty releases
final-release-branches = ["main"] # nonempty list; false is invalid
pre-release-branches = ["main"] # false allows any branch
dev-release-branches = false # any branch
# testpypi-username = "alice" # required for TestPyPI: example-package-alice; ignored for PyPI
github-release-publish = true
github-release-types = ["pre", "final"] # [] creates no GitHub releases

CLI policy options override TOML, which overrides defaults. Boolean false and empty lists retain their meaning. Unknown settings fail. Use --help on each command for options; there are no force or skip-check flags. Workflow generation settings do not belong in pyproject.toml.

Accepted versions are exactly canonical X.Y.Z, X.Y.Z.devN, X.Y.ZaN, X.Y.ZbN, or X.Y.ZrcN. Alternatives such as 1.2.3.rc1 are rejected. Epochs, local versions, post releases, compound suffixes and two-component versions are rejected. Release tags must be v<version> and point to the current HEAD. Nopt never creates or moves tags.

A restricted release group requires the tagged commit to be reachable from at least one existing branch selected by its policy. A detached checkout is valid. Every branch list must be nonempty. Prerelease and development policies can use false to allow any branch. Final releases always require a branch list.

Each list can mix literal names and patterns with one trailing * after a nonempty prefix. The wildcard matches zero or more characters within the final branch-name component. Matching is case-sensitive. For example, release/1.* matches release/1.5 and release/1.6. A branch such as release/1.6/hotfix needs a selector that includes its extra component. Local checks use local branches. GitHub Actions uses fetched origin remote-tracking branches. Only concrete branch refs qualify.

Set final-release-branches = ["main", "release/1.*"] in [tool.nopt], or pass --final-release-branches main 'release/1.*' on the command line. Quote the pattern so your shell passes it through unchanged. Use a version of nopt that supports patterns for all commands in the release workflow.

New branches that match a pattern can authorize releases under the same ancestry rule. Control who can create or update matching branches through your repository settings.

Dirty status comes directly from git status --porcelain=v1 -z --untracked-files=all. All tracked changes and nonignored untracked files in the checkout count, even when they are not packaged. Git's ignore rules determine what is ignored; nopt does not guess build/cache directories or inspect backend source manifests. Default dirty allowance is dev only. This is independent of tag-to-HEAD equality.

Changelog

Use a base-version section, shared by dev/pre/final releases:

## [1.2.3] - UNRELEASED

### Added

- Describe the changes.

Exactly one matching level-two section is required and the complete section is used as release notes. Its body must contain a nonblank line that does not start with #. Dev/pre require UNRELEASED; final releases require a real YYYY-MM-DD date. Nopt never changes dates. changelog = false or --no-changelog disables changelog policy for package-only releases. Requested GitHub releases require changelog extraction and the checked release-notes.md in the bundle; disable GitHub publication to use changelog = false for those release types.

Command flow

Command or workflow step Responsibility
nopt ci-preflight Reject an existing index version, then check source, tag, branch, dirty policy and changelog
Project CI Your lint and tests
nopt build Repeat eligibility checks, build from the checkout using isolated python -m build --installer=uv, validate artifacts and create the bundle
Actions upload / approval / download Preserve the original bundle and gate publishing
nopt publish-release-preflight --bundle PATH Verify bundle integrity and current commit/tag/workflow identity, then recheck index absence and live GitHub state
PyPA publishing action OIDC authentication, attestations and PyPI/TestPyPI upload
nopt publish-github-release --bundle PATH If configured, wait for exact PyPI filenames and hashes, then publish the GitHub release with the original distributions and their checksums

GitHub latest marking uses Git tag refs, not index versions, tag dates or GitHub release creation order. Only the greatest canonical final-version v-prefixed tag is eligible; older maintenance versions and all dev/pre releases use make_latest=false. Unsupported tags are ignored. The current final tag must appear in the reference snapshot. GitHub publication reads matching tag refs from the repository's Git database API, so this decision has no PyPI dependency. GitHub-only publication remains future planning; the current command still verifies the preceding index upload.

When GitHub release publication is disabled or the release group is excluded, successful PyPI upload ends publishing. There is no post-upload index polling in that path. Preflight refuses any index record for the target version, even an empty, partial or yanked record; only HTTP 404 means absent. Network/API errors fail immediately.

Use --check-only when nopt owns the action (build, publish-github-release); normal actions always run their checks too. Standalone preflights gate external steps. Build checks-only checks release eligibility without producing artifacts; it cannot validate artifacts that have not been built.

Local checks and builds

Select local mode explicitly:

nopt ci-preflight --local
nopt build --local --check-only
nopt build --local --output /absolute/path/to/new-bundle
nopt publish-release-preflight --local --bundle /absolute/path/to/new-bundle

Local mode derives project/version/commit from the checkout and the expected tag from the version. --project PATH selects another checkout; --tag is local-only and must identify the same existing canonical tag pointing to HEAD. Local mode checks local branches without fetching. GHA checks fetched repository branches and binds the release bundle to the repository, run ID, GITHUB_REF, and GITHUB_SHA. Local package preflight requires both HEAD and the tag recorded in the bundle to resolve to the bundle's commit. It uses local Git data without fetching. Policy and notes come from the bundle. A local bundle is not accepted for GHA publishing. Local GitHub release publishing is not supported.

Builds run directly from the checkout with the project's configured backend. Build-dependency isolation and the frontend's default sdist-then-wheel behavior remain enabled. Backend-generated files such as build/ or egg-info should be ignored by the client project's Git rules. Nopt neither copies the source tree nor excludes directories itself.

If [build-system].requires lists setuptools-git-metadata without an environment marker and pyproject.toml contains [tool.setuptools-git-metadata], nopt checks the full Git commit in the built wheel and source distribution before creating the bundle. It checks the plugin's packages list when provided. Otherwise, it checks top-level packages identified by __init__.py in the artifacts. This check expects a src/ layout in the source distribution.

TestPyPI always requires a valid username suffix. For TestPyPI builds, eligibility checks run first against the original project name. Nopt saves the raw pyproject.toml bytes, parses with tomllib, changes project.name and writes temporary TOML using tomli-w. The temporary file may lose comments and formatting. After the build, finally cleanup restores the exact original bytes in both local and GHA modes, including when rewriting or building fails. Pre-existing uncommitted edits are preserved; nopt does not reset the file to HEAD. Other backend-generated checkout files remain the client's responsibility.

Static project.name is still required, but alternate valid TOML spellings such as quoted tables/keys or dotted keys are supported. No staging copy is made, and import names remain unchanged. Later commands independently derive the same effective name from the original project.name and configured suffix. Both publishing commands read configuration from the original pyproject.toml stored in the verified bundle. Each invocation applies only its own CLI overrides; overrides are never carried between steps. Overrides must be compatible with the saved distribution name and available release notes; publishing never rebuilds or regenerates missing content.

Output must be a new directory; if it is inside the checkout, it must be Git-ignored. Add release-bundle/ to .gitignore to use the default output path.

The bundle contains the wheel and sdist under dist/, the original pyproject.toml, optional release-notes.md, the release.json manifest, and its release.json.sha256sum checksum. Publishing verifies the manifest bytes before parsing them, then verifies the exact set of payload files and their checksums using paths relative to the bundle root. The GitHub artifact and workflow run supply the trust boundary for that handoff.

The manifest records the original hashes, distribution identity, source commit and tag, pre-build dirty status, and GitHub Actions run identity when available. Publishing reloads the original project configuration and applies any CLI overrides for that invocation. GitHub uses the bundled changelog text as the release body. Nopt does not inspect generated runtime _version.py or require setuptools-git-metadata.

For older bundles with the internal SHA256SUMS file, use the nopt version that built the bundle.

Both GHA publishing jobs consume the bundle without a source checkout. Source dirty, branch and changelog checks and artifact metadata inspection are completed before bundling. Publishing checks bundle integrity and expected identity, then repeats only mutable external checks: existing index/release records, live tag refs, uploaded filenames/hashes and latest-final tag ranking. Local GitHub-release bundle acquisition remains deferred.

Generate a workflow

nopt workflow-template --output .github/workflows/release.yml

The command refuses to overwrite an existing file. Without --output, it prints the template. The CI job calls .github/workflows/test.yml; change that path to ci.yml or your project's CI workflow as needed, and enable its workflow_call trigger. Release commands use uv's default Python selection with nopt's Python requirement. The template uses tag triggers, full checkout history, separate jobs and 90-day artifact retention. The build job records the immutable artifact ID; downstream jobs download that exact ID rather than resolving an artifact name again. Edit the template directly; generation has no persistent TOML options.

Before enabling publication:

  • Pin the tool requirement and review action revisions. Repository-based action references are already pinned as name@sha # version.
  • Configure the pypi GitHub environment and approvals.
  • Register the repository/workflow/environment as a PyPI Trusted Publisher.
  • For TestPyPI, set repository = "testpypi", use the TestPyPI environment/publisher, and set the publishing action's TestPyPI upload URL.

Generation does not change settings. The upload action can add attestation sidecars to the publishing job's disposable bundle download. The stored build artifact remains unchanged; the GitHub release job downloads it afresh by artifact ID. The template archives the publishing directory, including generated attestations, as evidence even on upload failure. Only the publisher has id-token: write; only the GitHub release job has contents: write.

Limits and deferred recovery

GitHub publication creates a draft from the bundled release notes and attaches the original wheel, sdist, and a SHA256SUMS file for those two distributions. With all three assets in the same directory, run sha256sum -c SHA256SUMS to verify the distributions. The workflow artifact retains the full release bundle.

After uploading the assets, nopt refreshes the live tag and latest ranking, then publishes the draft. Assets are in place before publication makes an immutable release permanent. Checks-only makes no draft or uploads.

Existing published or visible draft GitHub releases for the tag cause failure. Automatic release/asset reconciliation and partial PyPI upload recovery are deferred. If draft creation succeeds but an upload or pre-publication check fails, the draft is left unpublished. An unsuccessful or unconfirmed final publication request can leave uncertain remote state; inspect it manually. A retry fails if either the draft or published release exists. An owner must review the original evidence and handle recovery manually. Do not rebuild or re-upload a published version. Expired Actions artifacts limit recovery; retain original bytes/evidence separately when needed. Same-tag workflow runs are serialized without automatic cancellation.

Publication jobs download the exact artifact ID from the build job output. A job-only rerun can reuse that bundle within the same workflow run. The manifest records the attempt that built the bundle. A full rerun builds a new bundle if preflight passes. Before retrying package upload, confirm the version is absent from the index. If both distributions are already present, retry only GitHub finalization with the original bundle. Nopt checks the index filenames and hashes and requires that GitHub have no release or draft for the tag.

Backend-specific source selection is delegated to the backend through python-build. Nopt does not calculate a source-file fingerprint or promise that backend builds leave the checkout untouched. Build hooks run project code; only run nopt on trusted projects. No production package migrations are included.

Develop

uv sync --group dev
uvx tox -e lint
uvx tox

CI runs tox with tox-uv on Linux, macOS and Windows for CPython 3.11–3.15 and PyPy 3.11–3.12. Integration tests use real local Git repositories and isolated wheel/sdist builds. Build tests exercise both setuptools and Hatchling, with and without TestPyPI name rewriting. No tests perform package publication, create GitHub releases or change remote settings.

CLI failures propagate their exceptions and tracebacks; successful commands return JSON where applicable. nopt --help describes the commands and nopt --version reports the installed distribution version.

A valid, nonempty testpypi-username is mandatory when repository = "testpypi". For that target, omitted, empty, whitespace, boolean and other non-string values fail configuration validation before build or publication checks. For PyPI the username is ignored, so one project configuration can keep the TestPyPI suffix ready without renaming production distributions.

Metadata

Release files for nopt 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nopt 0.2.0
File Size Uploaded Provenance Actions
nopt-0.2.0.tar.gz 50.7 kB With provenance Details for nopt-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nopt 0.2.0
File Interpreter ABI Platform Actions
nopt-0.2.0-py3-none-any.whl Python 3 none any Details for nopt-0.2.0-py3-none-any.whl

Total release size: 82.9 kB

Release files / nopt-0.2.0.tar.gz

Download URL nopt-0.2.0.tar.gz
Size 50.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cae26a9e2b5ff0f0df580b7396640acfc678f01791fae2aa6819946d6691a413
BLAKE2b-256 checksum
How to use checksums
6c299b103092bfa8d34516410cf506e8354b420a5f134dbf2a3d34ab67257f8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / nopt-0.2.0-py3-none-any.whl

Download URL nopt-0.2.0-py3-none-any.whl
Size 32.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45e8d09d07060fc8b916a48aaa9797748abefa37e637b309e79f9abbce2e2698
BLAKE2b-256 checksum
How to use checksums
d3bb1095f31c38df3e7a933dedabf3847e3e1e7f05ef23621210eb9e2560bb2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for nopt 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nopt-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page