You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔧 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
Copy file name to clipboardExpand all lines: DEVELOPERS.md
+57-13Lines changed: 57 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,21 +67,65 @@ twine upload dist/*
67
67
68
68
### 4. Using GitHub Actions for Automatic Publishing
69
69
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.
71
71
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:
81
73
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:
85
129
86
130
1. Log in to your PyPI account at https://pypi.org/
0 commit comments