-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (48 loc) · 1.7 KB
/
Copy pathpublish.yml
File metadata and controls
56 lines (48 loc) · 1.7 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
name: Publish
on:
push:
tags: ['v[0-9]+.[0-9]+.[0-9]+']
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Tag must match pyproject.toml
run: |
tag="${GITHUB_REF_NAME#v}"
ver="$(python -c 'import tomllib,pathlib; print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])')"
[ "$tag" = "$ver" ] || { echo "tag $tag != pyproject $ver"; exit 1; }
- run: pip install -e ".[dev]" build
# The suite stubs the transport, so it needs no API key and makes no network calls.
- run: pytest -q
- run: ruff check .
- run: mypy src
- run: python -m build # hatchling; writes sdist + wheel to dist/
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # mandatory for trusted publishing; nothing else is needed
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
# No username, no password, no PYPI_API_TOKEN — the publisher is registered on PyPI
# against this repo, this workflow filename and the `pypi` environment above. PEP 740
# attestations are generated and uploaded automatically. The job holding id-token
# deliberately runs no project code of its own.
- uses: pypa/gh-action-pypi-publish@release/v1