| 1 |
--- |
| 2 |
title: Release Process |
| 3 |
description: Step-by-step guide for creating and publishing new releases of django-guardian. |
| 4 |
--- |
| 5 |
|
| 6 |
# Release Process |
| 7 |
|
| 8 |
!!! warning "Maintainers Only" |
| 9 |
The release workflow can only be triggered by project maintainers with the required permissions. |
| 10 |
|
| 11 |
This document describes the steps to follow when creating a new release of `django-guardian`. |
| 12 |
Whether you are creating a standard release, a release candidate (RC), or a hotfix release, |
| 13 |
the general process follows the same pattern. |
| 14 |
|
| 15 |
## Prerequisites |
| 16 |
|
| 17 |
Before starting a release, make sure you have: |
| 18 |
|
| 19 |
- Write access to the [django-guardian repository](https://github.com/django-guardian/django-guardian) |
| 20 |
- Permission to trigger GitHub Actions workflows |
| 21 |
- A local clone of the repository, up to date with the remote |
| 22 |
- The development environment synced locally: |
| 23 |
|
| 24 |
```shell |
| 25 |
uv sync --group dev |
| 26 |
``` |
| 27 |
|
| 28 |
## Step 1: Run Tests Locally |
| 29 |
|
| 30 |
Before any release, all tests **must** pass. For extra safety, run the test suite locally before |
| 31 |
pushing any version bump: |
| 32 |
|
| 33 |
```shell |
| 34 |
uv run tox run |
| 35 |
``` |
| 36 |
|
| 37 |
Or if you want to run a quick check with a single Python/Django combination: |
| 38 |
|
| 39 |
```shell |
| 40 |
uv run pytest --cov=guardian --cov-report=xml --cov-report=term |
| 41 |
``` |
| 42 |
|
| 43 |
!!! tip |
| 44 |
Running tests locally before pushing helps catch issues early, before the CI pipeline runs. |
| 45 |
This is especially important for releases because a failed release workflow can leave things |
| 46 |
in an inconsistent state. |
| 47 |
|
| 48 |
## Step 2: Update the Version in `pyproject.toml` |
| 49 |
|
| 50 |
Open `pyproject.toml` and update the `version` field under `[project]` according to |
| 51 |
[Semantic Versioning 2.0](https://semver.org/): |
| 52 |
|
| 53 |
```toml |
| 54 |
[project] |
| 55 |
version = "X.Y.Z" |
| 56 |
``` |
| 57 |
|
| 58 |
- **Major** (`X`): Increment for breaking/incompatible changes. |
| 59 |
- **Minor** (`Y`): Increment for new features that are backward-compatible. |
| 60 |
- **Patch** (`Z`): Increment for backward-compatible bug fixes. |
| 61 |
- **Release Candidate**: Append `rc<N>` suffix (e.g. `3.4.0rc1`). |
| 62 |
|
| 63 |
Commit this change: |
| 64 |
|
| 65 |
```shell |
| 66 |
git add pyproject.toml |
| 67 |
git commit -m "Bump version to X.Y.Z" |
| 68 |
git push |
| 69 |
``` |
| 70 |
|
| 71 |
## Step 3: Trigger the Release Workflow |
| 72 |
|
| 73 |
Navigate to **Actions** → **[Release and Publish](https://github.com/django-guardian/django-guardian/actions/workflows/release-publish.yml)** on GitHub, then click **"Run Workflow"**. |
| 74 |
|
| 75 |
You will be presented with three inputs: |
| 76 |
|
| 77 |
### 3.1 Workflow Branch (Dropdown) |
| 78 |
|
| 79 |
The dropdown at the top ("Use workflow from") determines **which branch the workflow file itself is read from**. |
| 80 |
This is _not_ necessarily the branch being released. Select the branch that contains the version of the |
| 81 |
workflow you want to use (typically `main`). |
| 82 |
|
| 83 |
!!! note "Workflow branch ≠ Release branch" |
| 84 |
The branch selected in the dropdown controls which version of the workflow YAML is executed. |
| 85 |
The branch/SHA you type into the input field below is the actual code that will be built and released. |
| 86 |
These are two separate concepts. |
| 87 |
|
| 88 |
### 3.2 Branch or Commit SHA to Release |
| 89 |
|
| 90 |
Type the **branch name** or **commit SHA** of the code you want to release: |
| 91 |
|
| 92 |
| Scenario | Value to enter | |
| 93 |
|------------------------|-----------------------------------------------------| |
| 94 |
| Standard release | `main` | |
| 95 |
| Release candidate (RC) | `main` (or a specific commit SHA from `main`) | |
| 96 |
| Hotfix release | The hotfix branch name or a specific commit SHA | |
| 97 |
|
| 98 |
### 3.3 Tag |
| 99 |
|
| 100 |
Enter the version tag that matches the version you set in `pyproject.toml` (e.g. `3.4.0` or `3.4.0rc1`). |
| 101 |
|
| 102 |
## Step 4: Verify the Release |
| 103 |
|
| 104 |
After the workflow completes, verify that: |
| 105 |
|
| 106 |
1. The package was published to [PyPI](https://pypi.org/project/django-guardian/) |
| 107 |
2. A new tag was created in the repository |
| 108 |
3. A new release entry was created in [GitHub Releases](https://github.com/django-guardian/django-guardian/releases) |
| 109 |
|
| 110 |
If it is a **breaking release**, edit the release notes on GitHub to include an **"Upgrade Instructions"** section. |
| 111 |
|
| 112 |
--- |
| 113 |
|
| 114 |
## Release Types |
| 115 |
|
| 116 |
### Standard (Full) Release |
| 117 |
|
| 118 |
A standard release ships stable, production-ready code from the `main` branch. |
| 119 |
|
| 120 |
1. Ensure `main` is up to date and all tests pass. |
| 121 |
2. Update `pyproject.toml` → `version` (remove any `rc` suffix if upgrading from a release candidate). |
| 122 |
3. Commit and push to `main`. |
| 123 |
4. Trigger the workflow: |
| 124 |
- **Workflow branch (dropdown):** `main` |
| 125 |
- **Branch to release:** `main` |
| 126 |
- **Tag:** the version number (e.g. `3.4.0`) |
| 127 |
|
| 128 |
### Release Candidate (RC) |
| 129 |
|
| 130 |
A release candidate allows testing a new version before making it generally available. |
| 131 |
|
| 132 |
1. Keep changes on `main` and prepare the RC version there. |
| 133 |
2. Update `pyproject.toml` → `version` with an `rc` suffix (e.g. `3.4.0rc1`). |
| 134 |
3. Commit and push to `main`. |
| 135 |
4. Trigger the workflow: |
| 136 |
- **Workflow branch (dropdown):** the branch containing the workflow file you want to use |
| 137 |
- **Branch to release:** `main` (or a specific commit SHA from `main`) |
| 138 |
- **Tag:** the RC version (e.g. `3.4.0rc1`) |
| 139 |
|
| 140 |
!!! info |
| 141 |
RC releases are marked as **pre-release** in GitHub Releases and are published to PyPI as |
| 142 |
pre-release versions (pip will not install them by default unless `--pre` is specified). |
| 143 |
|
| 144 |
### Hotfix Release |
| 145 |
|
| 146 |
For urgent fixes that need to go out outside the normal release cycle: |
| 147 |
|
| 148 |
1. Create a hotfix branch from the tag of the current release. |
| 149 |
2. Apply the fix and update `pyproject.toml` → `version` (increment the patch version). |
| 150 |
3. Run tests locally and push. |
| 151 |
4. Trigger the workflow with the hotfix branch name or commit SHA. |
| 152 |
5. After a successful release, merge the hotfix back into `main`. |
| 153 |
|
| 154 |
--- |
| 155 |
|
| 156 |
## What the Workflow Does |
| 157 |
|
| 158 |
When triggered, the **Release and Publish** workflow will: |
| 159 |
|
| 160 |
1. **Run the full test suite** against the specified branch/commit. |
| 161 |
2. **Build** the Python package (sdist and wheel). |
| 162 |
3. **Upload** the package to [PyPI](https://pypi.org/project/django-guardian/) using a trusted publisher. |
| 163 |
4. **Tag** the repository with the specified version tag. |
| 164 |
5. **Create a GitHub Release** (full release or pre-release depending on the tag format). |
| 165 |
|
| 166 |
## Troubleshooting |
| 167 |
|
| 168 |
| Problem | Solution | |
| 169 |
|------------------------------------|------------------------------------------------------------------------------------------------| |
| 170 |
| Workflow fails on tests | Fix the failing tests, push again, and re-trigger the workflow. | |
| 171 |
| Version tag already exists | Delete the existing tag (`git tag -d <tag> && git push origin :refs/tags/<tag>`) and re-run. | |
| 172 |
| Package not appearing on PyPI | Check the workflow logs for upload errors. Ensure the trusted publisher is configured on PyPI. | |
| 173 |
| Wrong code was released | Yank the release on PyPI, delete the tag, fix the issue, and re-release with a new patch bump. | |