Skip to content

Commit 6e80f56

Browse files
committed
Add GitHub Actions workflow for automated PyPI publishing
1 parent 630ce01 commit 6e80f56

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
name: Publish to PyPI
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
id-token: write
13+
14+
jobs:
15+
build-and-release:
16+
runs-on: ubuntu-latest
17+
environment: release
18+
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v4
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v2
25+
26+
- name: Sync dependencies
27+
run: uv sync --all-extras --dev
28+
29+
- name: Run packaging checks
30+
run: uv run python -m compileall copilot_proxy
31+
32+
- name: Build distributions
33+
run: uv build
34+
35+
- name: Validate metadata
36+
run: uvx twine check dist/*
37+
38+
- name: Publish to PyPI
39+
if: github.event_name == 'push'
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
packages-dir: dist
43+
verbose: true
44+
45+
- name: Create GitHub release
46+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
47+
uses: softprops/action-gh-release@v2
48+
with:
49+
tag_name: ${{ github.ref_name }}
50+
generate_release_notes: true
51+
files: |
52+
dist/copilot_proxy-*.tar.gz
53+
dist/copilot_proxy-*.whl

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ Use `uv run pytest` (once tests are added) or `uvx ruff check .` for linting.
140140

141141
Both `uv publish` commands expect the relevant API token to be available in the `UV_PUBLISH_TOKEN` environment variable.
142142

143+
### GitHub Actions trusted publisher
144+
145+
This repository includes `.github/workflows/publish.yml`, which builds and uploads releases automatically on GitHub tag releases. To enable it:
146+
147+
1. Create a PyPI trusted publisher (pending or project-specific) pointing at:
148+
- **Project**: `copilot-proxy`
149+
- **Owner**: `modpotato`
150+
- **Repository**: `copilot-proxy`
151+
- **Workflow**: `publish.yml`
152+
- **Environment**: `release`
153+
2. In GitHub, create the matching repository environment (`Settings → Environments → New environment → release`).
154+
3. Push a tag (e.g. `v0.1.0`) to GitHub (`git push origin v0.1.0`). The workflow will build with `uv`, publish to PyPI via OIDC, and create the GitHub release automatically.
155+
4. For dry runs, use the **Run workflow** button; the manual dispatch builds and validates without publishing or creating a release.
156+
143157
## License
144158

145159
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)