Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 2df8aa2

Browse files
authored
Merge pull request #3 from BlueCentre/fix-pypi-publishing
Fix PyPI publishing and add release documentation
2 parents 1a59c15 + 2267876 commit 2df8aa2

2 files changed

Lines changed: 99 additions & 3 deletions

File tree

.github/workflows/python-ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ jobs:
118118
runs-on: ubuntu-latest
119119
environment: publish
120120
permissions:
121-
id-token: write # Required for PyPI publishing with trusted publishing
121+
id-token: write # Required for PyPI trusted publishing
122+
contents: read # Required for actions/checkout
122123

123124
steps:
124125
- name: Download built packages
@@ -127,5 +128,24 @@ jobs:
127128
name: dist
128129
path: dist/
129130

130-
- name: Publish to PyPI
131-
uses: pypa/gh-action-pypi-publish@release/v1
131+
- name: Display packages to be published
132+
run: |
133+
echo "Packages to be published:"
134+
ls -la dist/
135+
136+
# Option 1: Use Trusted Publishing (OIDC)
137+
- name: Publish to PyPI using Trusted Publishing
138+
if: ${{ !env.ACT && env.USE_TRUSTED_PUBLISHING == 'true' }}
139+
uses: pypa/gh-action-pypi-publish@release/v1
140+
with:
141+
verbose: true
142+
print-hash: true
143+
144+
# Option 2: Use API Token
145+
- name: Publish to PyPI using Token
146+
if: ${{ !env.ACT && (env.USE_TRUSTED_PUBLISHING != 'true') }}
147+
uses: pypa/gh-action-pypi-publish@release/v1
148+
with:
149+
password: ${{ secrets.PYPI_API_TOKEN }}
150+
verbose: true
151+
print-hash: true

RELEASE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Release Process for cli-code-agent
2+
3+
This document outlines the steps to release new versions of the `cli-code-agent` package to PyPI.
4+
5+
## Prerequisites
6+
7+
1. GitHub repository access with permissions to push tags and create releases
8+
2. PyPI account with permissions to publish the package
9+
10+
## Setup
11+
12+
### 1. Configure PyPI API Token
13+
14+
You can use either Trusted Publishing (OIDC) or a PyPI API token for publishing:
15+
16+
#### Option A: API Token (Simpler)
17+
18+
1. Generate a PyPI API token:
19+
- Go to https://pypi.org/manage/account/
20+
- Navigate to API tokens and create a new token with scope limited to the `cli-code-agent` project
21+
- Copy the token value (it will only be shown once)
22+
23+
2. Add the token to GitHub repository secrets:
24+
- Go to your GitHub repository → Settings → Secrets and variables → Actions
25+
- Create a new repository secret named `PYPI_API_TOKEN`
26+
- Paste the PyPI token value
27+
28+
#### Option B: Trusted Publishing (More Secure)
29+
30+
Set up Trusted Publishing between GitHub and PyPI:
31+
32+
1. On PyPI:
33+
- Go to your project page
34+
- Navigate to "Settings" → "Publishing"
35+
- Add a new "Pending publisher"
36+
- Select GitHub as the workflow
37+
- Enter `BlueCentre/cli-code` as the owner/repo
38+
- Enter `.github/workflows/python-ci.yml` as the workflow name
39+
- Save the publisher
40+
41+
2. On GitHub:
42+
- Create an environment named `publish` in your repository settings
43+
- Set the environment variable `USE_TRUSTED_PUBLISHING=true`
44+
45+
### 2. Creating a Release
46+
47+
1. Update version in `pyproject.toml`:
48+
```toml
49+
version = "x.y.z" # Update this line
50+
```
51+
52+
2. Commit the version change:
53+
```bash
54+
git add pyproject.toml
55+
git commit -m "Bump version to x.y.z"
56+
```
57+
58+
3. Create and push a tag:
59+
```bash
60+
git tag -a vx.y.z -m "Release version x.y.z"
61+
git push origin main
62+
git push origin vx.y.z
63+
```
64+
65+
4. Monitor the CI workflow in GitHub Actions to verify the release process completes successfully.
66+
67+
5. Check that the package appears on PyPI at https://pypi.org/project/cli-code-agent/
68+
69+
## Troubleshooting
70+
71+
If the release fails, check:
72+
73+
1. GitHub Actions logs for error messages
74+
2. Verify that the tag format is correct (should start with 'v')
75+
3. Ensure the PyPI token has not expired
76+
4. Verify that the package version is unique (PyPI rejects duplicate versions)

0 commit comments

Comments
 (0)