nopt 0.1.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicholas Hairs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include tox.ini
2
+ include docs/changelog.md
3
+ recursive-include tests *.py
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: nopt
3
+ Version: 0.1.0.dev0
4
+ Summary: Nicks Opinionated (Python Package) Publishing Tool
5
+ Author-email: Nicholas Hairs <info+nopt@nicholashairs.com>
6
+ License-Expression: MIT
7
+ Project-URL: GitHub, https://github.com/nhairs/nicks-opinionated-python-package-publishing-tool
8
+ Requires-Python: >=3.11
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENCE
11
+ Requires-Dist: build>=1.2.2
12
+ Requires-Dist: packaging>=24
13
+ Requires-Dist: uv>=0.8
14
+ Requires-Dist: tomli-w>=1.2
15
+ Dynamic: license-file
16
+
17
+ # Nicks Opinionated (Python Package) Publishing Tool
18
+
19
+ `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.
20
+
21
+ 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.
22
+
23
+ ## Install
24
+
25
+ Install from a reviewed checkout:
26
+
27
+ ```sh
28
+ python -m pip install .
29
+ nopt --help
30
+ ```
31
+
32
+ The project has not been published to PyPI. Workflow templates install nopt from its Git repository; pin that requirement and review the pinned action references before enabling production publishing.
33
+
34
+ ## Configure a project
35
+
36
+ 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:
37
+
38
+ ```toml
39
+ [project]
40
+ name = "example-package"
41
+ version = "1.2.3.dev4"
42
+
43
+ [tool.nopt]
44
+ changelog = "docs/changelog.md" # false disables extraction and date/content checks
45
+ repository = "pypi" # or "testpypi"
46
+ allow-dirty = ["dev"] # [] forbids all dirty releases
47
+ final-release-branches = ["main"] # nonempty list; false is invalid
48
+ pre-release-branches = ["main"] # false allows any branch
49
+ dev-release-branches = false # any branch
50
+ # testpypi-username = "alice" # required for TestPyPI: example-package-alice; ignored for PyPI
51
+ github-release-publish = true
52
+ github-release-types = ["pre", "final"] # [] creates no GitHub releases
53
+ ```
54
+
55
+ 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.
56
+
57
+ 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.
58
+
59
+ A restricted release group requires the commit to be reachable from at least one configured branch; it need not be the latest commit. Names are literal, with no globs. Empty branch lists are invalid. Final releases always require a restriction; pre/dev accept explicit false. A detached checkout is valid.
60
+
61
+ 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.
62
+
63
+ ### Changelog
64
+
65
+ Use a base-version section, shared by dev/pre/final releases:
66
+
67
+ ```markdown
68
+ ## [1.2.3] - UNRELEASED
69
+
70
+ ### Added
71
+
72
+ - Describe the changes.
73
+ ```
74
+
75
+ 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.
76
+
77
+ ## Command flow
78
+
79
+ | Command or workflow step | Responsibility |
80
+ | --- | --- |
81
+ | `nopt ci-preflight` | Reject an existing index version, then check source, tag, branch, dirty policy and changelog |
82
+ | Project CI | Your lint and tests |
83
+ | `nopt build` | Repeat eligibility checks, build from the checkout using isolated `python -m build --installer=uv`, validate artifacts and create the bundle |
84
+ | Actions upload / approval / download | Preserve the original bundle and gate publishing |
85
+ | `nopt publish-release-preflight --bundle PATH` | Verify bundle integrity and current commit/tag/workflow identity, then recheck index absence and live GitHub state |
86
+ | PyPA publishing action | OIDC authentication, attestations and PyPI/TestPyPI upload |
87
+ | `nopt publish-github-release --bundle PATH` | If configured, wait for exact PyPI filenames/hashes, then publish the GitHub release and original assets |
88
+
89
+ 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.
90
+
91
+ 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.
92
+
93
+ 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.
94
+
95
+ ### Local checks and builds
96
+
97
+ Select local mode explicitly:
98
+
99
+ ```sh
100
+ nopt ci-preflight --local
101
+ nopt build --local --check-only
102
+ nopt build --local --output /absolute/path/to/new-bundle
103
+ nopt publish-release-preflight --local --bundle /absolute/path/to/new-bundle
104
+ ```
105
+
106
+ 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 requires matching `GITHUB_REF`, `GITHUB_SHA`, repository, run ID and attempt. Local package preflight uses only local Git HEAD as its expected commit; policy and notes come from the bundle. A local bundle is not accepted for GHA publishing. Local GitHub release publishing is not supported.
107
+
108
+ 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.
109
+
110
+ 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.
111
+
112
+ 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.
113
+
114
+ 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.
115
+
116
+ The bundle contains `dist/` (wheel + sdist), the original `pyproject.toml`, optional `release-notes.md`, `release.json` and standard `SHA256SUMS`. `release-notes.md` holds the extracted changelog section used as the GitHub release body, so publication uses the same checked text as the build. Manifest hash keys are relative to the bundle root. Release identity binds original hashes, actual distribution identity, source commit/tag and pre-build dirty status, and GHA run identity when available. It does not save resolved configuration or CLI overrides. SHA256SUMS includes release.json; the GitHub artifact/run identity supplies the workflow trust boundary. Checksums alone are not signatures. The package does not inspect generated runtime `_version.py` or require setuptools-git-metadata.
117
+
118
+ 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.
119
+
120
+ ### Generate a workflow
121
+
122
+ ```sh
123
+ nopt workflow-template --output .github/workflows/release.yml
124
+ ```
125
+
126
+ The command refuses to overwrite an existing file. Without `--output`, it prints the template. Replace the failing `<your CI goes here>` placeholder with your CI. 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.
127
+
128
+ Before enabling publication:
129
+
130
+ - Pin the tool requirement and review action revisions. Repository-based action references are already pinned as `name@sha # version`.
131
+ - Configure the `pypi` GitHub environment and approvals.
132
+ - Register the repository/workflow/environment as a PyPI Trusted Publisher.
133
+ - For TestPyPI, set `repository = "testpypi"`, use the TestPyPI environment/publisher, and set the publishing action's TestPyPI upload URL.
134
+
135
+ Generation does not change settings. Keep distributions passed to the upload action in a separate copy so generated attestations do not mutate the original verified bundle. The template archives that publication directory as evidence, including on upload failure. Only the publisher has `id-token: write`; only the GitHub release job has `contents: write`.
136
+
137
+ ## Limits and deferred recovery
138
+
139
+ GitHub publication creates an internal draft, uploads every verified original asset,
140
+ refreshes the live tag and latest ranking, then publishes the draft. Assets are in
141
+ place before publication makes an immutable release permanent. Checks-only makes
142
+ no draft or uploads.
143
+
144
+ 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. The initial template also binds bundles to a run attempt and does not implement failed-job rerun recovery; do not use reruns to attempt another package upload. Same-tag workflow runs are serialized without automatic cancellation.
145
+
146
+ 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.
147
+
148
+ ## Develop
149
+
150
+ ```sh
151
+ uv sync --group dev
152
+ uvx tox -e lint
153
+ uvx tox
154
+ ```
155
+
156
+ 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.
157
+
158
+
159
+ After the initial nopt publication, change the template's tool installation/commands
160
+ to `uvx nopt ...`; until then it installs from Git. This migration remains TODO.
161
+
162
+ CLI failures propagate their exceptions and tracebacks; successful commands return
163
+ JSON where applicable. `nopt --help` describes the commands and `nopt --version`
164
+ reports the installed distribution version.
165
+
166
+
167
+ A valid, nonempty `testpypi-username` is mandatory when `repository = "testpypi"`.
168
+ For that target, omitted, empty, whitespace, boolean and other non-string values fail configuration
169
+ validation before build or publication checks.
170
+ For PyPI the username is ignored, so one project configuration can keep the
171
+ TestPyPI suffix ready without renaming production distributions.
172
+
173
+ The current workflow binding includes the build attempt number. Re-running only
174
+ a publication job with an earlier attempt's bundle is rejected even within the
175
+ same workflow run. Publish-only rerun support remains part of deferred recovery
176
+ planning; nopt does not silently rebuild or reuse a partially published release.
@@ -0,0 +1,160 @@
1
+ # Nicks Opinionated (Python Package) Publishing Tool
2
+
3
+ `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.
4
+
5
+ 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.
6
+
7
+ ## Install
8
+
9
+ Install from a reviewed checkout:
10
+
11
+ ```sh
12
+ python -m pip install .
13
+ nopt --help
14
+ ```
15
+
16
+ The project has not been published to PyPI. Workflow templates install nopt from its Git repository; pin that requirement and review the pinned action references before enabling production publishing.
17
+
18
+ ## Configure a project
19
+
20
+ 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:
21
+
22
+ ```toml
23
+ [project]
24
+ name = "example-package"
25
+ version = "1.2.3.dev4"
26
+
27
+ [tool.nopt]
28
+ changelog = "docs/changelog.md" # false disables extraction and date/content checks
29
+ repository = "pypi" # or "testpypi"
30
+ allow-dirty = ["dev"] # [] forbids all dirty releases
31
+ final-release-branches = ["main"] # nonempty list; false is invalid
32
+ pre-release-branches = ["main"] # false allows any branch
33
+ dev-release-branches = false # any branch
34
+ # testpypi-username = "alice" # required for TestPyPI: example-package-alice; ignored for PyPI
35
+ github-release-publish = true
36
+ github-release-types = ["pre", "final"] # [] creates no GitHub releases
37
+ ```
38
+
39
+ 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.
40
+
41
+ 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.
42
+
43
+ A restricted release group requires the commit to be reachable from at least one configured branch; it need not be the latest commit. Names are literal, with no globs. Empty branch lists are invalid. Final releases always require a restriction; pre/dev accept explicit false. A detached checkout is valid.
44
+
45
+ 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.
46
+
47
+ ### Changelog
48
+
49
+ Use a base-version section, shared by dev/pre/final releases:
50
+
51
+ ```markdown
52
+ ## [1.2.3] - UNRELEASED
53
+
54
+ ### Added
55
+
56
+ - Describe the changes.
57
+ ```
58
+
59
+ 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.
60
+
61
+ ## Command flow
62
+
63
+ | Command or workflow step | Responsibility |
64
+ | --- | --- |
65
+ | `nopt ci-preflight` | Reject an existing index version, then check source, tag, branch, dirty policy and changelog |
66
+ | Project CI | Your lint and tests |
67
+ | `nopt build` | Repeat eligibility checks, build from the checkout using isolated `python -m build --installer=uv`, validate artifacts and create the bundle |
68
+ | Actions upload / approval / download | Preserve the original bundle and gate publishing |
69
+ | `nopt publish-release-preflight --bundle PATH` | Verify bundle integrity and current commit/tag/workflow identity, then recheck index absence and live GitHub state |
70
+ | PyPA publishing action | OIDC authentication, attestations and PyPI/TestPyPI upload |
71
+ | `nopt publish-github-release --bundle PATH` | If configured, wait for exact PyPI filenames/hashes, then publish the GitHub release and original assets |
72
+
73
+ 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.
74
+
75
+ 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.
76
+
77
+ 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.
78
+
79
+ ### Local checks and builds
80
+
81
+ Select local mode explicitly:
82
+
83
+ ```sh
84
+ nopt ci-preflight --local
85
+ nopt build --local --check-only
86
+ nopt build --local --output /absolute/path/to/new-bundle
87
+ nopt publish-release-preflight --local --bundle /absolute/path/to/new-bundle
88
+ ```
89
+
90
+ 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 requires matching `GITHUB_REF`, `GITHUB_SHA`, repository, run ID and attempt. Local package preflight uses only local Git HEAD as its expected commit; policy and notes come from the bundle. A local bundle is not accepted for GHA publishing. Local GitHub release publishing is not supported.
91
+
92
+ 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.
93
+
94
+ 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.
95
+
96
+ 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.
97
+
98
+ 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.
99
+
100
+ The bundle contains `dist/` (wheel + sdist), the original `pyproject.toml`, optional `release-notes.md`, `release.json` and standard `SHA256SUMS`. `release-notes.md` holds the extracted changelog section used as the GitHub release body, so publication uses the same checked text as the build. Manifest hash keys are relative to the bundle root. Release identity binds original hashes, actual distribution identity, source commit/tag and pre-build dirty status, and GHA run identity when available. It does not save resolved configuration or CLI overrides. SHA256SUMS includes release.json; the GitHub artifact/run identity supplies the workflow trust boundary. Checksums alone are not signatures. The package does not inspect generated runtime `_version.py` or require setuptools-git-metadata.
101
+
102
+ 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.
103
+
104
+ ### Generate a workflow
105
+
106
+ ```sh
107
+ nopt workflow-template --output .github/workflows/release.yml
108
+ ```
109
+
110
+ The command refuses to overwrite an existing file. Without `--output`, it prints the template. Replace the failing `<your CI goes here>` placeholder with your CI. 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.
111
+
112
+ Before enabling publication:
113
+
114
+ - Pin the tool requirement and review action revisions. Repository-based action references are already pinned as `name@sha # version`.
115
+ - Configure the `pypi` GitHub environment and approvals.
116
+ - Register the repository/workflow/environment as a PyPI Trusted Publisher.
117
+ - For TestPyPI, set `repository = "testpypi"`, use the TestPyPI environment/publisher, and set the publishing action's TestPyPI upload URL.
118
+
119
+ Generation does not change settings. Keep distributions passed to the upload action in a separate copy so generated attestations do not mutate the original verified bundle. The template archives that publication directory as evidence, including on upload failure. Only the publisher has `id-token: write`; only the GitHub release job has `contents: write`.
120
+
121
+ ## Limits and deferred recovery
122
+
123
+ GitHub publication creates an internal draft, uploads every verified original asset,
124
+ refreshes the live tag and latest ranking, then publishes the draft. Assets are in
125
+ place before publication makes an immutable release permanent. Checks-only makes
126
+ no draft or uploads.
127
+
128
+ 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. The initial template also binds bundles to a run attempt and does not implement failed-job rerun recovery; do not use reruns to attempt another package upload. Same-tag workflow runs are serialized without automatic cancellation.
129
+
130
+ 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.
131
+
132
+ ## Develop
133
+
134
+ ```sh
135
+ uv sync --group dev
136
+ uvx tox -e lint
137
+ uvx tox
138
+ ```
139
+
140
+ 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.
141
+
142
+
143
+ After the initial nopt publication, change the template's tool installation/commands
144
+ to `uvx nopt ...`; until then it installs from Git. This migration remains TODO.
145
+
146
+ CLI failures propagate their exceptions and tracebacks; successful commands return
147
+ JSON where applicable. `nopt --help` describes the commands and `nopt --version`
148
+ reports the installed distribution version.
149
+
150
+
151
+ A valid, nonempty `testpypi-username` is mandatory when `repository = "testpypi"`.
152
+ For that target, omitted, empty, whitespace, boolean and other non-string values fail configuration
153
+ validation before build or publication checks.
154
+ For PyPI the username is ignored, so one project configuration can keep the
155
+ TestPyPI suffix ready without renaming production distributions.
156
+
157
+ The current workflow binding includes the build attempt number. Re-running only
158
+ a publication job with an earlier attempt's bundle is rejected even within the
159
+ same workflow run. Publish-only rerun support remains part of deferred recovery
160
+ planning; nopt does not silently rebuild or reuse a partially published release.
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - UNRELEASED
4
+
5
+ ### Added
6
+
7
+ - Initial release checks, isolated builds, release bundles and GitHub release publishing.
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=80"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nopt"
7
+ version = "0.1.0.dev0"
8
+ description = "Nicks Opinionated (Python Package) Publishing Tool"
9
+ requires-python = ">=3.11"
10
+ authors = [{name = "Nicholas Hairs", email = "info+nopt@nicholashairs.com"}]
11
+ readme = "README.md"
12
+ license = "MIT"
13
+ license-files = ["LICENCE"]
14
+ dependencies = ["build>=1.2.2", "packaging>=24", "uv>=0.8", "tomli-w>=1.2"]
15
+
16
+ [project.scripts]
17
+ nopt = "nopt.cli:main"
18
+
19
+ [project.urls]
20
+ GitHub = "https://github.com/nhairs/nicks-opinionated-python-package-publishing-tool"
21
+
22
+ [dependency-groups]
23
+ dev = ["pytest>=8", "black", "pylint", "pyrefly", "validate-pyproject[all]", "tox>=4", "tox-uv"]
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
27
+
28
+ [tool.setuptools.package-data]
29
+ nopt = ["workflow.yml"]
30
+
31
+ [tool.black]
32
+ line-length = 100
33
+
34
+ [tool.pylint.format]
35
+ max-line-length = 100
36
+
37
+ [tool.pylint.messages_control]
38
+ disable = ["useless-return"]
39
+
40
+ [tool.nopt]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Nicks Opinionated (Python Package) Publishing Tool."""
@@ -0,0 +1,5 @@
1
+ """Enable python -m nopt."""
2
+
3
+ from .cli import main
4
+
5
+ raise SystemExit(main())