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+ name : Publish package to PyPi
2+
3+ on :
4+ # CHANGED: This allows you to manually run the workflow from the
5+ # GitHub Actions tab (click 'Run workflow').
6+ workflow_dispatch :
7+ inputs :
8+ branch :
9+ description : ' Branch or tag to build from (e.g., main or v1.0.0)'
10+ required : true
11+ default : ' main'
12+
13+ jobs :
14+ push :
15+ runs-on : ubuntu-latest
16+
17+ # 1. SECURITY: Add permissions for OIDC token generation
18+ permissions :
19+ id-token : write # Grants permission to exchange a token with PyPI
20+ contents : read # Allows checkout of the repository
21+
22+ steps :
23+ - name : Checkout
24+ uses : actions/checkout@v5
25+ with :
26+ # Use the branch/tag provided in the manual input
27+ ref : ${{ github.event.inputs.branch }}
28+
29+ - name : Setup Python
30+ uses : actions/setup-python@v5
31+ with :
32+ # Use a stable, specific version
33+ python-version : 3.11
34+
35+ - name : Build package
36+ # Install the 'build' tool and then run it to create the sdist and wheel.
37+ run : |
38+ python -m pip install --upgrade pip
39+ python -m pip install build
40+ python -m build
41+
42+ # 2. SECURITY: Publish to PyPi (using Trusted Publisher)
43+ - name : Publish to PyPi (using Trusted Publisher)
44+ uses : pypa/gh-action-pypi-publish@release/v1
45+ # No manual secrets are needed!
You can’t perform that action at this time.
0 commit comments