File tree Expand file tree Collapse file tree 2 files changed +51
-31
lines changed
Expand file tree Collapse file tree 2 files changed +51
-31
lines changed Original file line number Diff line number Diff line change 1+ name : Publish to PyPI
2+ on :
3+ release :
4+ types : [published]
5+
6+ permissions :
7+ id-token : write
8+ contents : read
9+ jobs :
10+ test :
11+ uses : ./.github/workflows/quality.yml
12+
13+ publish :
14+ # This job publishes to PyPI when a GitHub release is created with a tag starting with 'v' on the release branch.
15+ #
16+ # Requirements:
17+ # - Repository admin must create a release with a tag starting with 'v' (e.g., v1.2.3)
18+ # - The tag must be created on the 'release' branch
19+ # - The release branch is protected by rulesets requiring all changes go through PR review
20+ #
21+ # Security notes:
22+ # - The tag and branch checks in this job are soft checks (can be bypassed by modifying workflow)
23+ # - Real security enforcement comes from the 'pypi' environment which requires manual approval by org admin
24+ # - This provides a final gate before any code is published to PyPI
25+ needs : test
26+ runs-on : ubuntu-latest
27+ if : startsWith(github.ref, 'refs/tags/v')
28+ environment :
29+ name : pypi
30+ steps :
31+ - name : Checkout code
32+ uses : actions/checkout@v4
33+ with :
34+ fetch-depth : 0 # Need full history to check branch ancestry
35+
36+ - name : Check if tag is on release branch
37+ run : |
38+ if ! git branch -r --contains ${{ github.ref }} | grep -q 'origin/release'; then
39+ echo "Error: Tag is not on release branch"
40+ exit 1
41+ fi
42+ echo "Tag verified to be on release branch"
43+
44+ - name : Download distributions
45+ uses : actions/download-artifact@v4
46+ with :
47+ name : distributions
48+ path : dist/
49+
50+ - name : Upload to PyPI
51+ uses : pypa/gh-action-pypi-publish@release/v1
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments