-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (88 loc) · 3.34 KB
/
python-publish.yml
File metadata and controls
104 lines (88 loc) · 3.34 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
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
build-and-verify:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
outputs:
artifact-name: ${{ steps.artifact-meta.outputs.name }}
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Build package
run: |
rm -rf dist
uv build
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
PACKAGE_VERSION="$(uv run python -c "import excelalchemy; print(excelalchemy.__version__)")"
NORMALIZED_TAG="${RELEASE_TAG#v}"
if [ "$PACKAGE_VERSION" != "$NORMALIZED_TAG" ]; then
echo "Release tag ($RELEASE_TAG) does not match excelalchemy.__version__ ($PACKAGE_VERSION)"
exit 1
fi
- name: Check package metadata
run: uvx twine check dist/*
- name: Smoke test wheel installation
run: |
uv venv .pkg-smoke-wheel --python 3.14
uv pip install --python .pkg-smoke-wheel/bin/python dist/*.whl
uv pip install --python .pkg-smoke-wheel/bin/python fastapi httpx python-multipart
.pkg-smoke-wheel/bin/python -c "import excelalchemy; print(excelalchemy.__version__)"
.pkg-smoke-wheel/bin/python scripts/smoke_package.py
.pkg-smoke-wheel/bin/python scripts/smoke_examples.py
.pkg-smoke-wheel/bin/python scripts/generate_example_output_assets.py
.pkg-smoke-wheel/bin/python scripts/smoke_docs_assets.py
- name: Smoke test source distribution installation
run: |
uv venv .pkg-smoke-sdist --python 3.14
uv pip install --python .pkg-smoke-sdist/bin/python dist/*.tar.gz
uv pip install --python .pkg-smoke-sdist/bin/python fastapi httpx python-multipart
.pkg-smoke-sdist/bin/python -c "import excelalchemy; print(excelalchemy.__version__)"
.pkg-smoke-sdist/bin/python scripts/smoke_package.py
.pkg-smoke-sdist/bin/python scripts/smoke_examples.py
.pkg-smoke-sdist/bin/python scripts/generate_example_output_assets.py
.pkg-smoke-sdist/bin/python scripts/smoke_docs_assets.py
- name: Set artifact metadata
id: artifact-meta
run: echo "name=python-package-dists" >> "$GITHUB_OUTPUT"
- name: Upload package distributions
uses: actions/upload-artifact@v7
with:
name: ${{ steps.artifact-meta.outputs.name }}
path: dist/
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: build-and-verify
environment: pypi
permissions:
contents: read
id-token: write
steps:
- name: Download package distributions
uses: actions/download-artifact@v8
with:
name: ${{ needs.build-and-verify.outputs.artifact-name }}
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1