Skip to content

Commit 127628d

Browse files
authored
feat(release): allow uv to manage build, release, and publish (#347)
* feat(release): allow uv to manage build, release, and publish * chore(uv.index): make explicit=true
1 parent 1eff5ce commit 127628d

File tree

3 files changed

+64
-108
lines changed

3 files changed

+64
-108
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
1+
---
12
name: Release
2-
3-
on:
3+
on:
44
workflow_dispatch:
55
inputs:
66
release_enabled:
7-
description: "Release the package to PyPI"
7+
description: Release the package to PyPI
88
required: true
99
type: boolean
10-
default: false
11-
10+
default: true
1211
jobs:
1312
release:
1413
runs-on: ubuntu-latest
15-
1614
steps:
17-
- name: Check out the repository
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 2
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v4
24-
with:
25-
python-version: '3.10'
26-
27-
- name: Upgrade pip
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip --version
31-
32-
- name: Install hatch
33-
run: |
34-
pip install hatch
35-
hatch --version
36-
37-
- name: Build package
38-
run: |
39-
hatch build
40-
41-
- name: Publish package on PyPI
42-
if: ${{ inputs.release_enabled }}
43-
uses: pypa/gh-action-pypi-publish@v1.8.10
44-
with:
45-
user: __token__
46-
password: ${{ secrets.PYPI_TOKEN }}
47-
48-
- name: Publish the release notes
49-
if: ${{ inputs.release_enabled }}
50-
uses: release-drafter/release-drafter@v5.25.0
51-
with:
52-
publish: true
53-
prerelease: false
54-
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
- name: Check out the repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 2
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v6
21+
- name: Build package
22+
run: |
23+
uv build
24+
- name: Publish package on PyPI
25+
if: ${{ inputs.release_enabled }}
26+
run: uv publish dist/*
27+
- name: Publish the release notes
28+
if: ${{ inputs.release_enabled }}
29+
uses: release-drafter/release-drafter@v6.1
30+
with:
31+
publish: true
32+
prerelease: false
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-release.yml

Lines changed: 34 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,42 @@
1+
---
12
name: Test Release
2-
3-
on:
3+
on:
44
workflow_dispatch:
55
workflow_run:
6-
workflows:
7-
- Build
8-
- Docker
6+
workflows: [Build]
97
branches: main
10-
types:
11-
- completed
12-
8+
types: [completed]
139
jobs:
1410
release:
1511
runs-on: ubuntu-latest
16-
1712
steps:
18-
- name: Check out the repository
19-
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 2
22-
23-
- name: Set up Python
24-
uses: actions/setup-python@v4
25-
with:
26-
python-version: '3.10'
27-
28-
- name: Upgrade pip
29-
run: |
30-
python -m pip install --upgrade pip
31-
pip --version
32-
33-
- name: Install hatch
34-
run: |
35-
pip install hatch
36-
hatch --version
37-
38-
- name: Check if there is a parent commit
39-
id: check-parent-commit
40-
run: |
41-
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
42-
43-
- name: Detect and tag new version
44-
id: check-version
45-
if: steps.check-parent-commit.outputs.sha
46-
uses: salsify/action-detect-and-tag-new-version@v2.0.3
47-
with:
48-
version-command: |
49-
bash -o pipefail -c "hatch -q version"
50-
51-
- name: Build package
52-
run: |
53-
hatch build
54-
55-
- name: Publish package on TestPyPI
56-
if: "steps.check-version.outputs.tag"
57-
uses: pypa/gh-action-pypi-publish@v1.8.10
58-
with:
59-
user: __token__
60-
password: ${{ secrets.TEST_PYPI_TOKEN }}
61-
repository-url: https://test.pypi.org/legacy/
62-
63-
- name: Publish the release notes
64-
uses: release-drafter/release-drafter@v5.25.0
65-
with:
66-
publish: false
67-
prerelease: true
68-
tag: ${{ steps.check-version.outputs.tag }}
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
13+
- name: Check out the repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 2
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v6
19+
- name: Check if there is a parent commit
20+
id: check-parent-commit
21+
run: |
22+
echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
23+
- name: Detect and tag new version
24+
id: check-version
25+
if: steps.check-parent-commit.outputs.sha
26+
uses: salsify/action-detect-and-tag-new-version@v2.0.3
27+
with:
28+
version-command: |
29+
cat __about__.py | grep '^__version__ = ' | cut -d '"' -f 2
30+
- name: Build package
31+
run: |
32+
uv build
33+
- name: Publish package on TestPyPI
34+
run: uv publish --index testpypi dist/*
35+
- name: Publish the release notes
36+
uses: release-drafter/release-drafter@v6.1
37+
with:
38+
publish: false
39+
prerelease: true
40+
tag: ${{ steps.check-version.outputs.tag }}
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ dev = [
9292
"mkdocstrings[python]>=0.29.1",
9393
"pytest-asyncio>=0.26.0",
9494
]
95+
96+
[[tool.uv.index]]
97+
name = "testpypi"
98+
url = "https://test.pypi.org/simple/"
99+
publish_url = "https://test.pypi.org/legacy/"
100+
explicit = true

0 commit comments

Comments
 (0)