Skip to content

Commit 04ed4da

Browse files
author
Nick Sullivan
committed
🔧 Update PyPI publishing workflow and documentation
- Switch from trusted publishing to API token authentication - Update Python version to 3.13 in workflow - Add PyPI-related words to VS Code spell checker - Expand documentation with both API token and trusted publishing methods
1 parent f1e24f2 commit 04ed4da

File tree

3 files changed

+62
-26
lines changed

3 files changed

+62
-26
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ jobs:
99
deploy:
1010
name: Upload release to PyPI
1111
runs-on: ubuntu-latest
12-
# Set up environment with URL to PyPI project
13-
environment:
14-
name: pypi
15-
url: https://pypi.org/p/heart-centered-prompts
16-
# Add id-token write permission for trusted publishing
17-
permissions:
18-
id-token: write
1912

2013
steps:
2114
- uses: actions/checkout@v3
@@ -25,7 +18,7 @@ jobs:
2518
- name: Set up Python
2619
uses: actions/setup-python@v4
2720
with:
28-
python-version: "3.x"
21+
python-version: "3.13"
2922

3023
- name: Install dependencies
3124
run: |
@@ -38,11 +31,9 @@ jobs:
3831
python -m build
3932
4033
- name: Publish package to PyPI
41-
uses: pypa/gh-action-pypi-publish@v1.8.10
34+
uses: pypa/gh-action-pypi-publish@release/v1
4235
with:
4336
packages-dir: python/dist/
44-
# No password needed with trusted publishing
45-
# Enable verbose output for debugging
37+
password: ${{ secrets.PYPI_API_TOKEN }}
4638
verbose: true
47-
# Print hash values of files being uploaded
4839
print-hash: true

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@
9595
"titleBar.inactiveBackground": "#ff66b299",
9696
"titleBar.inactiveForeground": "#15202b99"
9797
},
98-
"peacock.color": "#FF66B2"
98+
"peacock.color": "#FF66B2",
99+
"cSpell.words": ["PYPI", "setuptools"]
99100
}

DEVELOPERS.md

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,65 @@ twine upload dist/*
6767

6868
### 4. Using GitHub Actions for Automatic Publishing
6969

70-
Our repository is configured with GitHub Actions to automatically publish to PyPI when a new `releases/v*` tag is pushed. The workflow:
70+
Our repository is configured with GitHub Actions to automatically publish to PyPI when a new `releases/v*` tag is pushed.
7171

72-
1. Detects the new tag
73-
2. Sets up Python
74-
3. Builds the package
75-
4. Publishes to PyPI using the stored API token
76-
77-
To make this work:
78-
79-
- Ensure the `PYPI_API_TOKEN` secret is set in your GitHub repository settings
80-
- Simply create and push a tag following the pattern `releases/v*`
72+
We use PyPI's recommended "trusted publishing" approach, which allows secure authentication without API tokens. The workflow:
8173

82-
### Setting Up Your PyPI API Token
83-
84-
PyPI no longer accepts username/password authentication. You must use API tokens:
74+
1. Detects the new tag
75+
2. Sets up Python and builds the package
76+
3. Publishes to PyPI using OpenID Connect (OIDC) authentication
77+
78+
#### Setting Up Trusted Publishing
79+
80+
> **Note:** We're currently using the API token method for authentication. The instructions below are for future reference if you want to migrate to trusted publishing.
81+
82+
To set up trusted publishing in the future:
83+
84+
1. Create an environment in your GitHub repository settings:
85+
86+
- Go to Settings → Environments → New environment
87+
- Name it `pypi`
88+
- Add environment protection rules if desired
89+
90+
2. Configure trusted publishing on PyPI:
91+
92+
- Log in to your PyPI account at https://pypi.org/
93+
- Navigate to your project
94+
- Go to "Settings" → "Publishing"
95+
- Set up a new publisher with:
96+
- Publisher: GitHub Actions
97+
- Owner: TechNickAI
98+
- Repository name: heart-centered-prompts
99+
- Workflow name: Publish Python Package
100+
- Environment name: pypi
101+
102+
3. Modify the GitHub workflow file to use trusted publishing:
103+
```yaml
104+
jobs:
105+
deploy:
106+
name: Upload release to PyPI
107+
runs-on: ubuntu-latest
108+
environment:
109+
name: pypi
110+
url: https://pypi.org/p/heart-centered-prompts
111+
permissions:
112+
id-token: write
113+
steps:
114+
# ... existing steps ...
115+
- name: Publish package to PyPI
116+
uses: pypa/gh-action-pypi-publish@v1.8.10
117+
with:
118+
packages-dir: python/dist/
119+
# No password needed with trusted publishing
120+
verbose: true
121+
print-hash: true
122+
```
123+
124+
No API tokens needed with trusted publishing - the connection between GitHub and PyPI is secured through OpenID Connect!
125+
126+
#### Using API Tokens (Current Method)
127+
128+
We're currently using API tokens for PyPI authentication. Here's how to set them up:
85129
86130
1. Log in to your PyPI account at https://pypi.org/
87131
2. Go to Account Settings → API tokens

0 commit comments

Comments
 (0)