Skip to content

Commit 2a6c979

Browse files
added docs for realease
1 parent 5abf848 commit 2a6c979

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release (TestPyPI only)
1+
name: Release (PyPi or TestPyPI)
22

33
on:
44
push:

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This code is used to showcase a number of good software practices. See the next
1616
usage
1717
docs_local
1818
docs_github
19+
release
1920
structure
2021
api
2122

docs/release.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
Release procedure
2+
=================
3+
4+
This page describes the recommended steps to create, test, and publish a release
5+
for this project. Follow the "prerelease first, stable later" flow to avoid
6+
accidental uploads to PyPI.
7+
8+
Prerequisites
9+
-------------
10+
11+
- Add repository secrets in GitHub (Settings → Secrets and variables → Actions):
12+
- `TEST_PYPI_API_TOKEN` — API token created on TestPyPI (value begins with
13+
``pypi-``).
14+
- `PYPI_API_TOKEN` — API token created on PyPI (value begins with
15+
``pypi-``).
16+
- Verify `pyproject.toml` metadata (`project.name` and `version`).
17+
- Confirm build tooling is available locally when needed:
18+
``python -m pip install --upgrade build twine``
19+
20+
Release checklist
21+
-----------------
22+
23+
1. Bump the version in `pyproject.toml`.
24+
25+
- For a prerelease/test run use a prerelease version (example: ``0.2.0-rc1``).
26+
- For a stable release use a normal version (example: ``0.2.0``).
27+
28+
2. Commit the version change and create a tag.
29+
30+
Annotated prerelease (publishes to TestPyPI):
31+
32+
.. code-block:: bash
33+
34+
git add pyproject.toml
35+
git commit -m "Bump version to 0.2.0-rc1"
36+
git tag -a v0.2.0-rc1 -m "v0.2.0-rc1 - prerelease"
37+
git push origin v0.2.0-rc1
38+
39+
Annotated stable release (publishes to PyPI):
40+
41+
.. code-block:: bash
42+
43+
git add pyproject.toml
44+
git commit -m "Bump version to 0.2.0"
45+
git tag -a v0.2.0 -m "v0.2.0 - release"
46+
git push origin v0.2.0
47+
48+
3. Verify the CI run
49+
50+
- The release workflow builds the sdist and wheel and uploads them as an
51+
artifact, then publishes to TestPyPI or PyPI depending on the tag name.
52+
- Tags containing a dash (``-``) publish to TestPyPI. Tags without a dash
53+
publish to PyPI. This repository uses that convention intentionally so you
54+
can test on TestPyPI first.
55+
56+
4. Smoke-test the published package (for prerelease)
57+
58+
Install from TestPyPI and run quick checks:
59+
60+
.. code-block:: bash
61+
62+
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple python-project-template-AS==0.2.0rc1
63+
64+
- Verify that imports and basic functionality work as expected.
65+
66+
5. Promote to stable (after verification)
67+
68+
- Update `pyproject.toml` version to the stable version (e.g. ``0.2.0``),
69+
commit, tag, and push the stable tag. The workflow will publish to PyPI.
70+
71+
Deleting tags
72+
-------------
73+
74+
If you accidentally pushed a tag and want to remove it from the remote:
75+
76+
.. code-block:: bash
77+
78+
# delete remote tag
79+
git push origin --delete refs/tags/v0.2.0
80+
81+
# delete local tag
82+
git tag -d v0.2.0
83+
84+
Removing GitHub Releases
85+
------------------------
86+
87+
- To remove a GitHub Release created by CI, use the Releases page in the
88+
repository or the GitHub CLI:
89+
90+
.. code-block:: bash
91+
92+
gh release delete v0.2.0 --repo andreascaglioni/python-project-template -y
93+
94+
Notes and tips
95+
--------------
96+
97+
- The release workflow in `.github/workflows/release.yml` has two publish jobs:
98+
- `publish-testpypi` runs for prerelease tags (contains ``-``) and uses
99+
`TEST_PYPI_API_TOKEN`.
100+
- `publish-pypi` runs for stable tags (no ``-``) and uses `PYPI_API_TOKEN`.
101+
- The workflow intentionally disables OIDC for publishing and uses repository
102+
secrets. Keep your secrets rotated and never commit them.
103+
- Consider protecting the PyPI publish step with a GitHub environment that
104+
requires manual approval for extra safety.
105+
106+
Changelog and release notes
107+
---------------------------
108+
109+
- Prepare changelog entries in `CHANGELOG.md` under an "Unreleased" section
110+
and move them into a versioned section when releasing.
111+
112+
Acknowledgments
113+
---------------
114+
115+
Automated by repository release workflow. If you find a problem, open an issue
116+
or submit a PR.

0 commit comments

Comments
 (0)