Skip to content

Commit 6c25776

Browse files
committed
publish with uv - close #34
1 parent 70ff032 commit 6c25776

36 files changed

Lines changed: 127 additions & 61 deletions

.coveragerc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ source = herald
55
branch = True
66
omit =
77
*/migrations/*
8-
*/tests/*
9-
runtests.py
8+
*/tests/*

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ jobs:
4040
- name: Run tests
4141
run: |
4242
uv run coverage run --source herald runtests.py -v 2
43+
uv run coverage run -m django test --settings=tests.settings --pythonpath=. -v 2
4344
- name: Report coverage to Codecov
4445
uses: codecov/codecov-action@v3

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- #35 via MR #36 - Add security policy via `SECURITY.md`
66
- #33 via MR #38 - Switch to `uv` for package dependencies
7+
- #34 - Switch to `uv` for building and publishing package
78
- Chore/Docs: Drop official support for Python 3.9 (EOL October 2025)
89

910

CONTRIBUTING.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,25 @@
4545

4646
## Running Tests
4747

48-
This will run with a SQLite3 in-memory database:
48+
This will run tests with a SQLite3 in-memory database and coverage:
49+
```bash
50+
uv run coverage run -m django test --settings=tests.settings --pythonpath=. -v 2
51+
```
4952

53+
* `--pythonpath=.` is required to set the context otherwise you will recieve the error `ModuleNotFoundError: No module named 'tests'`
54+
* `-v 3` sets the verbosity high enough to be able to see pre-migrate handlers, migrations, and post-migrate handlers.
55+
56+
Show the coverage report to gain feedback on missing test case coverage:
5057
```bash
51-
uv run runtests.py -v 2
58+
uv run coverage report --show-missing
5259
```
5360

61+
### Supported environment variables for tests
62+
63+
| Environment Name | Description | Default Value |
64+
| ----- | ----- | ----- |
65+
| `HERALD_TEST_DB_NAME` | The path and name to the SQLite DB name. | `db.sqlite3` |
66+
5467
## Running Server to See Views
5568

5669
You will need to run migrations:
@@ -61,4 +74,6 @@ uv run manage.py migrate
6174
Run server:
6275
```bash
6376
uv run manage.py runserver 0.0.0.0:8000
64-
```
77+
```
78+
79+
Open a browser to: [http://localhost:8000/](http://localhost:8000)

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# django-heralder
1+
# Django Heralder
22

33
[![Latest PyPI version](https://badge.fury.io/py/django-heralder.svg)](https://pypi.python.org/pypi/django-heralder)
44
[![Tests](https://github.com/peterfarrell/django-heralder/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/peterfarrell/django-heralder/actions/workflows/ci.yml)
@@ -28,26 +28,30 @@ As of Django-Heralder `v0.4.0`, Django-Heralder has diverged from original proje
2828

2929
### Supported Django / Python Versions
3030

31-
We try to make Heralder support all versions of django that django supports + all versions in between.
31+
We try to make Heralder support all versions of LTS that Django supports + all versions in between.
3232

3333
For python, Heralder supports all versions of python that the above versions of django support.
3434

35-
As of Heralder v0.4.0, we support:
35+
We currently support:
3636

3737
| Django | Python `3.10` | Python `3.11` | Python `3.12` | Python `3.13` |
38-
| --- | --- | --- | --- | --- | --- |
38+
| --- | --- | --- | --- | --- |
3939
| `3.2.x` | **Y** | - | - | - |
4040
| `4.2.x` | **Y** | **Y** | **Y** | - |
4141
| `5.2.x` | **Y** | **Y** | **Y** | **Y** |
4242

4343
### Installation
4444

45-
1. Install Django-Heralder using your favority packagement management tool (e.g. `pip`, `uv`, etc.)
45+
1. Install Django Heralder using your favority packagement management tool (e.g. `pip`, `uv`, etc.)
4646

4747
```bash
4848
pip install django-heralder
4949
```
5050

51+
```bash
52+
uv add django-heralder
53+
```
54+
5155
2. In your `settings.py` file, add `herald` and `django.contrib.sites` to `INSTALLED_APPS`:
5256

5357
```python

RELEASE.md

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,82 @@
1-
# How to Release
1+
# How to Build and Publish the Package to PyPi
22

3-
## Prerequistics
3+
Django Heralder uses UV to build and publish the package.
44

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.
638

739
```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
949
```
1050

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.
1254

13-
1. Bump version number in `herald/__init__.py` and commit to source control.
55+
4. Build the package:
1456

15-
2. Verify entry in `CHANGELOG.md`.
57+
```bash
58+
rm -rf dist/
59+
uv build --no-sources
60+
```
1661

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)
2263

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:
2465

2566
```bash
26-
twine upload dist/*
67+
uv publish --index [pypi|testpypi]
2768
```
2869

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:
3073

3174
1. Go to [Draft a new release](https://github.com/peterfarrell/django-heralder/releases/new)
3275
2. Choose tag. If you have not created a tag yet, you can create one "on publish". Use the format of `vX.X.X`.
3376
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)

pyproject.toml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[tool.hatch.build.targets.wheel]
6+
packages = ["src/herald"]
7+
18
[project]
29
name = "django-heralder"
3-
version = "0.0.0"
10+
version = "0.5.1"
411
requires-python = ">=3.10,<3.14"
512
readme = "README.md"
613
license = "MIT"
@@ -16,8 +23,8 @@ dependencies = [
1623

1724
keywords = [
1825
"django",
19-
"notifications",
20-
"messaging",
26+
"notifications",
27+
"messaging",
2128
]
2229

2330
classifiers = [
@@ -52,3 +59,24 @@ dev = [
5259
"mock>=5.2.0",
5360
"pytz>=2025.2",
5461
]
62+
63+
[project.urls]
64+
Homepage = "https://github.com/peterfarrell/django-heralder"
65+
Repository = "https://github.com/peterfarrell/django-heralder.git"
66+
Issues = "https://github.com/peterfarrell/django-heralder/issues"
67+
Changelog = "https://github.com/peterfarrell/django-heralder/blob/main/CHANGELOG.md"
68+
69+
[tool.uv]
70+
package = true
71+
72+
[[tool.uv.index]]
73+
name = "testpypi"
74+
url = "https://test.pypi.org/simple/"
75+
publish-url = "https://test.pypi.org/legacy/"
76+
explicit = true
77+
78+
[[tool.uv.index]]
79+
name = "pypi"
80+
url = "https://pypi.org/simple/"
81+
publish-url = "https://pypi.org/legacy/"
82+
explicit = true

runtests.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

setup.cfg

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)