|
1 | | -# How to Release |
| 1 | +# How to Build and Publish the Package to PyPi |
2 | 2 |
|
3 | | -## Prerequistics |
| 3 | +Django Heralder uses UV to build and publish the package. |
4 | 4 |
|
5 | | -1. Install `setuptools` and `twine`: |
| 5 | +## How to Choose a Version Number |
| 6 | + |
| 7 | +This library uses [Semantic Versioning (semver)](https://semver.org/), meaning versions follow the `MAJOR.MINOR.PATCH` format. |
| 8 | + |
| 9 | +``` |
| 10 | +1.2.3 |
| 11 | +^ ^ ^ |
| 12 | +| | | |
| 13 | +| | | ------- Patch |
| 14 | +| | --------- Minor |
| 15 | +``` |
| 16 | + |
| 17 | +Given a version number MAJOR.MINOR.PATCH, increment the: |
| 18 | + |
| 19 | +| Version Type | Example Version | Compatibility | Description | |
| 20 | +| ----- | ----- | ----- | ----- | |
| 21 | +| **PATCH** | `1.2.4` | Backward-compatible | Increment for bug fixes and minor, **backward-compatible** improvements. This includes documentation updates. | |
| 22 | +| **MINOR** | `1.3.0`| Backward-compatible | Increment for new features or improvements in a **backward-compatible** manner. | |
| 23 | +| **MAJOR** | `2.0.0` | Breaking changes (incompatible) | Increment for **breaking changes (incompatible)** that require engineers to modify their applications. This signals a significant release.| |
| 24 | + |
| 25 | +When incrementing the: |
| 26 | + |
| 27 | +* **MAJOR:** Reset the both **MINOR** to` 0` and **PATCH** to `0` |
| 28 | + * Ex: `1.8.9` becomes `2.0.0` |
| 29 | +* **MINOR:** Reset the **PATCH** to `0` |
| 30 | + * Ex: `1.8.9` becomes `1.9.0` |
| 31 | + |
| 32 | +## Publish Package Using UV |
| 33 | + |
| 34 | +### Manual |
| 35 | + |
| 36 | +1. Update the `CHANGELOG.md` file. Move any `[Unreleased]` items into a version using an appropriate SemVer version (see above). |
| 37 | +2. Bump the version number in the `pyproject.toml` using the `uv version` command below by providing a positional arugment. This is update the `pyproject.toml` file. |
6 | 38 |
|
7 | 39 | ```bash |
8 | | - pip install setuptools twine |
| 40 | + uv version 0.5.1 |
| 41 | + >> Resolved 31 packages in 346ms |
| 42 | + >> Built django-heralder @ file:///Users/django/Projects/django-heralder |
| 43 | + >> Prepared 1 package in 725ms |
| 44 | + >> Uninstalled 1 package in 1ms |
| 45 | + >> Installed 1 package in 3ms |
| 46 | + >> - django-heralder==0.5.0 (from file:///Users/django/Projects/django-heralder) |
| 47 | + >> + django-heralder==0.5.1 (from file:///Users/django/Projects/django-heralder) |
| 48 | + >> django-heralder 0.5.0 => 0.5.1 |
9 | 49 | ``` |
10 | 50 |
|
11 | | -## Procedure |
| 51 | + * Read more about the [`uv version`](https://docs.astral.sh/uv/guides/package/#updating-your-version) command. |
| 52 | + |
| 53 | +3. Commit the file changes to `main` and push to GitHub. |
12 | 54 |
|
13 | | -1. Bump version number in `herald/__init__.py` and commit to source control. |
| 55 | +4. Build the package: |
14 | 56 |
|
15 | | -2. Verify entry in `CHANGELOG.md`. |
| 57 | + ```bash |
| 58 | + rm -rf dist/ |
| 59 | + uv build --no-sources |
| 60 | + ``` |
16 | 61 |
|
17 | | -3. Build distribution: |
18 | | - |
19 | | - ```bash |
20 | | - python setup.py sdist bdist_wheel |
21 | | - ``` |
| 62 | + * Use `--no-sources` when building to publish per [recommendatation from UV](https://docs.astral.sh/uv/guides/publish/#building-your-package) |
22 | 63 |
|
23 | | -4. Upload the distribution to PyPI and follow the prompts to provide the API token: |
| 64 | +5. Publish the package to `pypi` (production), or `testpypi` (test) package repository: |
24 | 65 |
|
25 | 66 | ```bash |
26 | | - twine upload dist/* |
| 67 | + uv publish --index [pypi|testpypi] |
27 | 68 | ``` |
28 | 69 |
|
29 | | -5. Create a new release and tag on GitHub: |
| 70 | + Follow the prompts for a API username `__token__` and password (API token). You can configure an API token in your PyPI account or Test PyPI account. |
| 71 | + |
| 72 | +6. Create a new release and tag on GitHub: |
30 | 73 |
|
31 | 74 | 1. Go to [Draft a new release](https://github.com/peterfarrell/django-heralder/releases/new) |
32 | 75 | 2. Choose tag. If you have not created a tag yet, you can create one "on publish". Use the format of `vX.X.X`. |
33 | 76 | 3. Set the release title to the version. Ex: `vX.X.X` |
34 | | - 5. In the body for the release, copy the bullets of items from the `CHANGELOG.md`. |
| 77 | + 5. In the body for the release, copy the bullets of items from the `CHANGELOG.md`. |
| 78 | + |
| 79 | + |
| 80 | +### Using GithHub Trusted Publisher |
| 81 | + |
| 82 | +TODO: See [#39 - Enhance publishing using GitHub Actions and PyPI Trusted Publishers](https://github.com/peterfarrell/django-heralder/issues/39) |
0 commit comments