File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ name : Publish to PyPI
3+
4+ on :
5+ push :
6+ tags :
7+ - ' v*.*.*' # e.g. v1.2.3
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+ - uses : actions/setup-python@v5
15+ with :
16+ python-version : ' 3.x'
17+ - name : Install build tools
18+ run : pip install build tomli
19+ - name : Verify tag matches pyproject.toml version
20+ run : |
21+ TAG="${GITHUB_REF#refs/tags/v}"
22+ FILE_VER=$(python -c "import tomli;print(tomli.load(open('pyproject.toml'))['project']['version'])")
23+ [ "$TAG" = "$FILE_VER" ] || { echo "Tag $TAG != pyproject $FILE_VER"; exit 1; }
24+ - name : Build dists
25+ run : python -m build
26+ - name : Upload artifacts
27+ uses : actions/upload-artifact@v4
28+ with :
29+ name : dist
30+ path : dist/*
31+
32+ publish :
33+ needs : build
34+ runs-on : ubuntu-latest
35+ environment : pypi
36+ permissions :
37+ id-token : write
38+ contents : read
39+ steps :
40+ - uses : actions/download-artifact@v4
41+ with :
42+ name : dist
43+ path : dist
44+ - name : Publish to PyPI via OIDC
45+ uses : pypa/gh-action-pypi-publish@release/v1
You can’t perform that action at this time.
0 commit comments