File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Stage Python source distribution and wheel packages through GitHub Actions (GHA) to Python Package Index (PyPI).
2+ name : " Release: Python package"
3+
4+ on :
5+
6+ # Build and publish packages when running a release.
7+ push :
8+ tags :
9+ - ' *'
10+
11+ # Build packages on each pull request for validation purposes.
12+ pull_request :
13+
14+ # Build packages each night for validation purposes.
15+ schedule :
16+ - cron : ' 0 4 * * *'
17+
18+ # Allow the job to be triggered manually.
19+ workflow_dispatch :
20+
21+ jobs :
22+ build-and-publish :
23+ name : " Build and publish to PyPI"
24+ runs-on : ${{ matrix.os }}
25+ strategy :
26+ fail-fast : false
27+ matrix :
28+ os : ["ubuntu-latest"]
29+ python-version : ["3.13"]
30+ env :
31+ OS_TYPE : ${{ matrix.os }}
32+ PYTHON_VERSION : ${{ matrix.python-version }}
33+
34+ # Trusted publishing.
35+ # Specifying a GitHub environment is optional, but strongly encouraged
36+ environment : pypi
37+ permissions :
38+ # IMPORTANT: this permission is mandatory for Trusted Publishing
39+ id-token : write
40+
41+ steps :
42+ - name : Acquire sources
43+ uses : actions/checkout@v4
44+
45+ - name : Set up Python
46+ uses : actions/setup-python@v5
47+ with :
48+ python-version : ${{ matrix.python-version }}
49+
50+ - name : Set up uv
51+ uses : astral-sh/setup-uv@v6
52+ with :
53+ cache-dependency-glob : |
54+ setup.py
55+ pyproject.toml
56+ cache-suffix : ${{ matrix.python-version }}
57+ enable-cache : true
58+ version : " latest"
59+
60+ - name : Build package
61+ run : |
62+ uv pip install build
63+ python -m build
64+
65+ - name : Publish package to PyPI
66+ if : startsWith(github.event.ref, 'refs/tags')
67+ uses : pypa/gh-action-pypi-publish@release/v1
Original file line number Diff line number Diff line change 1+ # Release
2+
3+ Building Python packages and publishing to PyPI is automated
4+ using the GHA workflow ` release-pypi.yml ` .
5+
6+ To release the package, exercise those steps:
7+
8+ - Edit ` CHANGELOG.md ` , designating a new version. Commit the file
9+ using a commit message like ` Release 4.1.1 ` .
10+
11+ - Create a tag using the new version, including a ` v ` prefix, e.g.
12+ ``` shell
13+ git tag v4.1.1
14+ ```
15+
16+ - Push to remote.
17+ ``` shell
18+ git push && git push --tags
19+ ```
You can’t perform that action at this time.
0 commit comments