Repository navigation
54 lines (50 loc) · 1.48 KB
/
Copy pathrelease.yml
File metadata and controls
54 lines (50 loc) · 1.48 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
# Pushing a tag vX.Y.Z publishes that version to PyPI through trusted
# publishing: no token lives in the repository secrets. It needs, once per
# package, a (pending) publisher on pypi.org pointing at this repository,
# this workflow file and the `pypi` environment.
name: release
on:
push:
tags: ["v*"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Tag matches the package version
run: |
version=$(uv version --short)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME does not match pyproject version $version" >&2
exit 1
fi
- run: uv sync --locked
- run: uv run pytest
- 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/${{ github.event.repository.name }}/
permissions:
id-token: write
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
- name: GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --generate-notes