|
| 1 | +# Releasing pythainer |
| 2 | + |
| 3 | +This document records the exact steps to publish a new release of pythainer. |
| 4 | + |
| 5 | +Prereqs: |
| 6 | +- You have push access to the repo and the PyPI project. |
| 7 | +- `CHANGELOG.md` follows Keep a Changelog and Semantic Versioning. |
| 8 | +- Version in `pyproject.toml` is maintained manually (PEP 440). |
| 9 | +- CI is green on `main`. |
| 10 | + |
| 11 | +Versioning Tag format: `v0.X.Y` |
| 12 | + |
| 13 | +Date format: `YYYY-MM-DD`. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## 1) Prepare the release |
| 18 | + |
| 19 | +1. Pick the version number `0.X.Y`. |
| 20 | + |
| 21 | +2. Update `CHANGELOG.md`: |
| 22 | + - Add a new section `## [0.X.Y] - YYYY-MM-DD` under `[Unreleased]`. |
| 23 | + - Move curated changes from `[Unreleased]` into `0.X.Y`. |
| 24 | + |
| 25 | +3. Bump the version in `pyproject.toml`: |
| 26 | + ```toml |
| 27 | + [project] |
| 28 | + version = "0.X.Y" |
| 29 | + ``` |
| 30 | + |
| 31 | +4. Sanity checks locally: |
| 32 | + |
| 33 | + ```bash |
| 34 | + ./scripts/all_checks.sh |
| 35 | + pytest -q |
| 36 | + git clean -ndx |
| 37 | + git status |
| 38 | + ``` |
| 39 | + |
| 40 | +5. Create a short-lived release branch and commit: |
| 41 | + ```bash |
| 42 | + git checkout -b release |
| 43 | + git add -u |
| 44 | + git commit -s -m "Release 0.X.Y" |
| 45 | + git push -u origin release |
| 46 | + ``` |
| 47 | + |
| 48 | +6. Open the corresponding PR on GitHub. When CI is green, merge. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## 2) Tag the release |
| 53 | + |
| 54 | +After the PR is merged: |
| 55 | + |
| 56 | +```bash |
| 57 | +git checkout main |
| 58 | +git pull --prune |
| 59 | +git tag -a "v0.X.Y" -m "Release v0.X.Y" |
| 60 | +git push origin v0.X.Y |
| 61 | +``` |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 3) Build artifacts locally |
| 66 | + |
| 67 | +Use a fresh clone and venv to avoid leaking deps: |
| 68 | + |
| 69 | +```bash |
| 70 | +git clone https://github.com/apaolillo/pythainer.git |
| 71 | +cd pythainer/ |
| 72 | +python3 -m venv .venv-release |
| 73 | +. .venv-release/bin/activate |
| 74 | +python3 -m pip install --upgrade pip |
| 75 | +python3 -m pip install --upgrade build twine |
| 76 | +python3 -m build # creates dist/*.whl and dist/*.tar.gz |
| 77 | +python3 -m twine check dist/* |
| 78 | +``` |
| 79 | + |
| 80 | +Quick inspection: |
| 81 | + |
| 82 | +* Confirm wheel exists (preferably `py3-none-any.whl` for pure Python). |
| 83 | +* Confirm tarball contains only expected files. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## 4) Publish to PyPI |
| 88 | + |
| 89 | +```bash |
| 90 | +# still in the .venv-release |
| 91 | +python3 -m twine upload dist/* |
| 92 | +``` |
| 93 | + |
| 94 | +You will need a `~/.pypirc` or to paste your `__token__` API token when prompted. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## 5) Verify the release |
| 99 | + |
| 100 | +* PyPI page: [https://pypi.org/project/pythainer/](https://pypi.org/project/pythainer/) |
| 101 | +* Clean venv install: |
| 102 | + |
| 103 | + ```bash |
| 104 | + python3 -m venv /tmp/venv-verify && . /tmp/venv-verify/bin/activate |
| 105 | + pip install -U pip |
| 106 | + pip install pythainer==0.X.Y |
| 107 | + pythainer --help |
| 108 | + deactivate |
| 109 | + ``` |
| 110 | +* Check that README renders correctly on PyPI. |
| 111 | +* Profit. |
0 commit comments