Repository navigation
94 lines (88 loc) · 2.96 KB
/
Copy pathpython-publish.yml
File metadata and controls
94 lines (88 loc) · 2.96 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Test, build and publish Python package
on:
pull_request:
push:
branches: [main]
tags: ['*']
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
- name: Sync locked project and development tools
run: uv sync --locked
- name: Check Python lint and formatting
run: |
uv run --locked ruff check .
uv run --locked ruff format --check .
- name: Check release version
if: startsWith(github.ref, 'refs/tags/')
run: |
uv run --locked python - <<'PY'
import os
import tomllib
from pathlib import Path
version = tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"]
tag = os.environ["GITHUB_REF_NAME"].removeprefix("v")
if tag != version:
raise SystemExit(f"Tag {tag!r} does not match package version {version!r}")
PY
- name: Build and validate distributions
run: |
uv build
uv run --locked twine check dist/*
- uses: actions/upload-artifact@v7.0.2
with:
name: distributions
path: dist/
if-no-files-found: error
test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14', '3.15']
steps:
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v8.0.2
with:
name: distributions
path: dist/
- name: Test project with locked dependencies
run: |
uv sync --locked
uv run --locked python -m unittest discover -s tests -v
- name: Install wheel in a clean environment and test public API
run: |
uv venv "$RUNNER_TEMP/client-test"
uv pip install --python "$RUNNER_TEMP/client-test/bin/python" dist/*.whl
uv pip check --python "$RUNNER_TEMP/client-test/bin/python"
"$RUNNER_TEMP/client-test/bin/python" -c 'import tu_ruc_python_client'
"$RUNNER_TEMP/client-test/bin/python" -m unittest discover -s tests -v
publish:
if: startsWith(github.ref, 'refs/tags/')
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: '0.13.0'
- uses: actions/download-artifact@v8.0.2
with:
name: distributions
path: dist/
- name: Publish tested distributions
run: uv publish dist/*
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}