Skip to content

Commit d95f5f8

Browse files
author
Guotong
committed
ci: skip PyPI publish when token is missing
1 parent 7b34fa1 commit d95f5f8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.github/workflows/publish.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
publish:
1111
runs-on: ubuntu-latest
1212
permissions:
13-
id-token: write
13+
contents: read
1414

1515
steps:
1616
- name: Checkout
@@ -29,6 +29,13 @@ jobs:
2929
twine check dist/*
3030
3131
- name: Publish to PyPI
32+
if: ${{ secrets.PYPI_API_TOKEN != '' }}
3233
uses: pypa/gh-action-pypi-publish@release/v1
3334
with:
3435
password: ${{ secrets.PYPI_API_TOKEN }}
36+
37+
- name: Skip PyPI publish (token not configured)
38+
if: ${{ secrets.PYPI_API_TOKEN == '' }}
39+
run: |
40+
echo "PYPI_API_TOKEN is not set. Skipping package upload."
41+
echo "To enable publish, add PYPI_API_TOKEN in repo Settings -> Secrets and variables -> Actions."

docs/release/publish-runbook.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
- Replace `<YOUR_HANDLE>` in launch copies.
88
- (Optional) Replace security email in `SECURITY.md`.
99

10+
## 0.5) Choose PyPI publish mode
11+
12+
Option A (simplest): API token
13+
14+
- In PyPI, create an API token (project-scoped recommended).
15+
- In GitHub repo: `Settings -> Secrets and variables -> Actions`
16+
- Add secret: `PYPI_API_TOKEN`
17+
18+
Option B: Trusted Publisher (OIDC)
19+
20+
- Configure Trusted Publisher on PyPI for this exact repo/workflow.
21+
- If claims do not match, you'll see `invalid-publisher`.
22+
- This repository currently defaults to API token mode.
23+
1024
## 1) Final local checks
1125

1226
```bash

0 commit comments

Comments
 (0)