Skip to content

Commit 5eb1a72

Browse files
authored
Merge pull request #195 from django-commons/uv
switch to uv
2 parents b7c88a7 + a20bc87 commit 5eb1a72

File tree

135 files changed

+2693
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+2693
-407
lines changed

.github/workflows/lint.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ permissions: read-all
44

55
on:
66
push:
7-
branches: main
7+
# branches: main
88
pull_request:
9+
workflow_call:
910
workflow_dispatch:
1011
inputs:
1112
debug:
@@ -50,12 +51,18 @@ jobs:
5051
id: sp
5152
with:
5253
python-version: ${{ matrix.python-version }}
54+
55+
- name: Install uv
56+
uses: astral-sh/setup-uv@v5
57+
with:
58+
enable-cache: true
5359
- name: Install Just
5460
uses: extractions/setup-just@v2
5561
- name: Install Dependencies
5662
run: |
57-
just init ${{ steps.sp.outputs.python-path }} install-docs
58-
just pin-dependency Django~=${{ matrix.django-version }}.0
63+
just setup ${{ steps.sp.outputs.python-path }}
64+
just test-lock Django~=${{ matrix.django-version }}.0
65+
just install-docs
5966
- name: Install Emacs
6067
if: ${{ github.event.inputs.debug == 'true' }}
6168
run: |

.github/workflows/release.yml

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,96 @@
1-
##
2-
# Derived from:
3-
# https://github.com/django-commons/django-commons-playground/blob/main/.github/workflows/release.yml
4-
#
51

62
name: Publish Release
73

84
permissions: read-all
95

6+
concurrency:
7+
# stop previous release runs if tag is recreated
8+
group: release-${{ github.ref }}
9+
cancel-in-progress: true
10+
1011
on:
1112
push:
1213
tags:
1314
- 'v*' # only publish on version tags (e.g. v1.0.0)
14-
workflow_dispatch:
15-
inputs:
16-
pypi:
17-
description: 'Publish to PyPi'
18-
required: true
19-
default: false
20-
type: boolean
21-
github:
22-
description: 'Publish a GitHub Release'
23-
required: true
24-
default: false
25-
type: boolean
26-
testpypi:
27-
description: 'Publish to TestPyPi'
28-
required: true
29-
default: true
30-
type: boolean
31-
32-
env:
33-
PYPI_URL: https://pypi.org/p/django-typer
34-
PYPI_TEST_URL: https://test.pypi.org/project/django-typer
3515

3616
jobs:
3717

18+
lint:
19+
permissions:
20+
contents: read
21+
actions: write
22+
uses: ./.github/workflows/lint.yml
23+
secrets: inherit
24+
25+
test:
26+
permissions:
27+
contents: read
28+
actions: write
29+
uses: ./.github/workflows/test.yml
30+
secrets: inherit
31+
3832
build:
3933
name: Build Package
4034
runs-on: ubuntu-latest
4135
permissions:
36+
contents: read
4237
actions: write
43-
38+
outputs:
39+
PACKAGE_NAME: ${{ steps.set-package.outputs.package_name }}
40+
RELEASE_VERSION: ${{ steps.set-package.outputs.release_version }}
4441
steps:
4542
- uses: actions/checkout@v4
4643
- name: Set up Python
4744
uses: actions/setup-python@v5
4845
with:
49-
python-version: "3.x"
50-
- name: Install pypa/build
51-
run:
52-
python3 -m pip install build --user
53-
- name: Build a binary wheel and a source tarball
54-
run: python3 -m build
46+
python-version: ">=3.11" # for tomlib
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
54+
run: |
55+
TAG_NAME=${GITHUB_REF#refs/tags/}
56+
echo "Verifying tag $TAG_NAME..."
57+
# if a tag was deleted and recreated we may have the old one cached
58+
# be sure that we're publishing the current tag!
59+
git fetch --force origin refs/tags/$TAG_NAME:refs/tags/$TAG_NAME
60+
61+
# verify signature
62+
curl -sL https://github.com/${{ github.actor }}.gpg | gpg --import
63+
git tag -v "$TAG_NAME"
64+
65+
# verify version
66+
RELEASE_VERSION=$(just validate_version $TAG_NAME)
67+
68+
# export the release version
69+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
70+
- name: Build the binary wheel and a source tarball
71+
run: just build
5572
- name: Store the distribution packages
5673
uses: actions/upload-artifact@v4
5774
with:
5875
name: python-package-distributions
5976
path: dist/
77+
- name: Set Package Name
78+
id: set-package
79+
run:
80+
PACKAGE_NAME=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")
81+
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV
6082

6183
publish-to-pypi:
6284
name: Publish to PyPI
63-
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.pypi == 'true') || github.event_name != 'workflow_dispatch' }}
6485
needs:
65-
- build
86+
- lint
87+
- test
88+
- build
89+
- publish-to-testpypi
6690
runs-on: ubuntu-latest
6791
environment:
6892
name: pypi
69-
url: ${{ env.PYPI_URL }}
93+
url: https://pypi.org/p/${{ needs.build.outputs.PACKAGE_NAME }}
7094
permissions:
7195
id-token: write # IMPORTANT: mandatory for trusted publishing
7296
steps:
@@ -80,10 +104,11 @@ jobs:
80104

81105
github-release:
82106
name: Publish GitHub Release
83-
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.github == 'true') || github.event_name != 'workflow_dispatch' }}
84107
runs-on: ubuntu-latest
85108
needs:
86-
- build
109+
- lint
110+
- test
111+
- build
87112
permissions:
88113
contents: write # IMPORTANT: mandatory for making GitHub Releases
89114
id-token: write # IMPORTANT: mandatory for sigstore
@@ -121,14 +146,13 @@ jobs:
121146
122147
publish-to-testpypi:
123148
name: Publish to TestPyPI
124-
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.testpypi == 'true') || github.event_name != 'workflow_dispatch' }}
125149
needs:
126150
- build
127151
runs-on: ubuntu-latest
128152

129153
environment:
130154
name: testpypi
131-
url: ${{ env.PYPI_TEST_URL }}
155+
url: https://test.pypi.org/project/${{ needs.build.outputs.PACKAGE_NAME }}
132156

133157
permissions:
134158
id-token: write # IMPORTANT: mandatory for trusted publishing
@@ -144,14 +168,3 @@ jobs:
144168
with:
145169
repository-url: https://test.pypi.org/legacy/
146170
skip-existing: true
147-
148-
# TODO fetch-data requires login
149-
# notify-django-packages:
150-
# name: Notify Django Packages
151-
# runs-on: ubuntu-latest
152-
# needs:
153-
# - publish-to-pypi
154-
# steps:
155-
# - name: Notify Django Packages
156-
# run:
157-
# curl -X GET "https://djangopackages.org/packages/django-typer/fetch-data/"

0 commit comments

Comments
 (0)