Repository navigation
133 lines (112 loc) · 4.14 KB
/
Copy pathpython-package.yml
File metadata and controls
133 lines (112 loc) · 4.14 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Build and test the Python package. Documentation is handled separately in docs.yml.
name: Python package
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Check lint
run: uv run ruff check .
- name: Check format
run: uv run ruff format --check .
- name: Check types
run: uv run ty check src/rtichoke
- name: Build package
run: uv build
- name: Verify vendored browser assets in wheel
run: |
uv run python - <<'PY'
from pathlib import Path
import zipfile
wheel = next(Path("dist").glob("*.whl"))
with zipfile.ZipFile(wheel) as archive:
names = set(archive.namelist())
prefix = "rtichoke/_vendor/rtichoke_viz/"
required = {
f"{prefix}VENDORED_FROM",
f"{prefix}rtichoke-viz-0.23.0.tar.gz",
f"{prefix}rtichoke-viz.js",
f"{prefix}rtichoke-viz.css",
f"{prefix}rtichoke-viz.schema.json",
f"{prefix}rtichoke-viz-v2.schema.json",
f"{prefix}rtichoke-viz-report.schema.json",
}
assert required <= names
assert f"{prefix}rtichoke-viz-0.22.3.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.22.2.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.22.1.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.22.0.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.20.2.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.20.1.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.20.0.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.19.0.tar.gz" not in names
assert f"{prefix}rtichoke-viz-0.14.0.tar.gz" not in names
PY
- name: Run tests
run: uv run pytest tests
- name: Show package version
run: grep -r "version" pyproject.toml || grep -r "__version__" rtichoke/ || python -c "import rtichoke; print(rtichoke.__version__)"
release:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for intentional release marker change
id: marker
shell: bash
run: |
if git diff --name-only HEAD^ HEAD | grep -qx '.github/release-version'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Install uv
if: steps.marker.outputs.changed == 'true'
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Validate release version
if: steps.marker.outputs.changed == 'true'
id: version
shell: bash
run: |
RELEASE_VERSION=$(tr -d '[:space:]' < .github/release-version)
PACKAGE_VERSION=$(sed -n 's/^version = "\([^"]*\)"/\1/p' pyproject.toml | head -n 1)
test -n "$RELEASE_VERSION"
test "$RELEASE_VERSION" = "$PACKAGE_VERSION"
echo "version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- name: Build package
if: steps.marker.outputs.changed == 'true'
run: uv build
- name: Publish to PyPI
if: steps.marker.outputs.changed == 'true'
run: uv publish
- name: Create GitHub release
if: steps.marker.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: gh release create "v${VERSION}" --target "${GITHUB_SHA}" --generate-notes --title "v${VERSION}"