-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (55 loc) · 1.77 KB
/
Copy pathpublish.yml
File metadata and controls
64 lines (55 loc) · 1.77 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
name: publish
# Publishes to PyPI via Trusted Publishing (OIDC) when a GitHub Release is
# published — no API token is stored. Configure the trusted publisher once on
# PyPI: project "lokf", owner "nicholsn", repo "lokf", workflow "publish.yml",
# environment "pypi".
on:
release:
types: [published]
workflow_dispatch:
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
# A release tag whose version was never bumped in pyproject.toml only
# surfaces at upload time, as an opaque PyPI "400 File already exists".
# Fail here instead, before the tests even run.
- name: Check the release tag matches the package version
if: github.event_name == 'release'
run: |
tag="${GITHUB_REF_NAME#v}"
packaged="$(uv version --short)"
if [ "$tag" != "$packaged" ]; then
echo "::error::Release tag v$tag does not match pyproject.toml version $packaged — bump the version, merge, then re-tag."
exit 1
fi
- name: Test (gate the release)
run: uv run --group dev pytest -q
- name: Build sdist + wheel
run: uv build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/lokf/
permissions:
id-token: write # OIDC token for Trusted Publishing
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1