Skip to content

Commit 137f5b1

Browse files
committed
add version checking and release shortcut
1 parent 9f34b98 commit 137f5b1

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

.github/workflows/debug.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
permissions:
2323
contents: read
2424

25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2527
steps:
2628
- uses: actions/checkout@v4
2729
- name: Set up Python ${{ github.event.inputs.python-version }}

.github/workflows/release.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,36 @@ jobs:
3737
actions: write
3838
outputs:
3939
PACKAGE_NAME: ${{ steps.set-package.outputs.package_name }}
40+
RELEASE_VERSION: ${{ steps.set-package.outputs.release_version }}
4041
steps:
4142
- uses: actions/checkout@v4
4243
- name: Set up Python
4344
uses: actions/setup-python@v5
4445
with:
4546
python-version: ">=3.11" # for tomlib
46-
- name: Verify Tag Signature
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v5
49+
with:
50+
enable-cache: true
51+
- name: Setup Just
52+
uses: extractions/setup-just@v2
53+
- name: Verify Tag
4754
run: |
4855
TAG_NAME=${GITHUB_REF#refs/tags/}
4956
echo "Verifying tag $TAG_NAME..."
5057
# if a tag was deleted and recreated we may have the old one cached
5158
# be sure that we're publishing the current tag!
5259
git fetch --force origin refs/tags/$TAG_NAME:refs/tags/$TAG_NAME
60+
61+
# verify signature
5362
curl -sL https://github.com/${{ github.actor }}.gpg | gpg --import
5463
git tag -v "$TAG_NAME"
55-
- name: Install uv
56-
uses: astral-sh/setup-uv@v5
57-
with:
58-
enable-cache: true
59-
- name: Setup Just
60-
uses: extractions/setup-just@v2
64+
65+
# verify version
66+
just verify_version $TAG_NAME
67+
68+
# export the release version
69+
echo "RELEASE_VERSION=${TAG_NAME}" >> $GITHUB_ENV
6170
- name: Build the binary wheel and a source tarball
6271
run: just build
6372
- name: Store the distribution packages

CONTRIBUTING.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ Additional dependency groups will need to be installed for some RDBMS:
8484
poetry install -E all --with oracle
8585
```
8686

87-
## Releases
87+
## Issuing Releases
8888

89-
The release workflow is triggered by tag creation. You must have git tag signing enabled.
89+
The release workflow is triggered by tag creation. You must have [git tag signing enabled](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits). Our justfile has a release shortcut:
9090

9191
```console
92-
git tag -s vX.X.X -m "X.X.X Release"
93-
git push origin vX.X.X
94-
```
92+
just release x.x.x
93+
```

justfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,20 @@ coverage:
205205
# run the command in the virtual environment
206206
run +ARGS:
207207
uv run {{ ARGS }}
208+
209+
210+
# validate the given version string against the lib version
211+
[script]
212+
validate_version VERSION:
213+
import re
214+
import tomllib
215+
import django_enum
216+
assert re.match(r"\d+[.]\d+[.]\w+", "{{ VERSION }}")
217+
assert "{{ VERSION }}" == tomllib.load(open('pyproject.toml', 'rb'))['project']['version']
218+
assert "{{ VERSION }}" == django_enum.__version__
219+
220+
# issue a relase for the given semver string (e.g. 2.1.0)
221+
release VERSION:
222+
@just _validate_version {{ VERSION }}
223+
git tag -s v{{ VERSION }} -m "{{ VERSION }} Release"
224+
git push origin {{ VERSION }}

0 commit comments

Comments
 (0)