Repository navigation
71 lines (67 loc) · 2.24 KB
/
Copy pathrelease.yml
File metadata and controls
71 lines (67 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Publish a release: build once, upload to TestPyPI, then, after a
# maintainer approves, upload the same files to PyPI. Runs when a version
# tag (v*) is pushed.
#
# Uploads use PyPI Trusted Publishing, so no API token is stored anywhere:
# pypi.org and test.pypi.org each have a trusted publisher registered for
# this repository, this workflow, and the job's environment (`pypi` or
# `testpypi`), and they accept the short-lived identity GitHub gives the job.
# The `pypi` environment (Settings → Environments) requires a reviewer, so
# the PyPI job waits until someone has installed the TestPyPI upload and
# approved the run. PyPI never accepts the same version twice, which is why
# TestPyPI comes first.
name: release
on:
push:
tags: ["v*"]
jobs:
build:
name: build the wheel and sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
- name: Tag matches the version in pyproject.toml
run: |
version="$(uv version --short)"
if [ "v${version}" != "${GITHUB_REF_NAME}" ]; then
echo "::error::tag ${GITHUB_REF_NAME} does not match version ${version} in pyproject.toml"
exit 1
fi
- run: uv build
- uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
testpypi:
name: publish to TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/project/geg-raft/
permissions:
id-token: write # Trusted Publishing
steps:
- uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- uses: astral-sh/setup-uv@v7
- run: uv publish --trusted-publishing always --publish-url https://test.pypi.org/legacy/ dist/*
pypi:
name: publish to PyPI
needs: testpypi
runs-on: ubuntu-latest
environment:
name: pypi # requires a reviewer's approval
url: https://pypi.org/project/geg-raft/
permissions:
id-token: write # Trusted Publishing
steps:
- uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- uses: astral-sh/setup-uv@v7
- run: uv publish --trusted-publishing always dist/*