|
| 1 | +# Publishing Setup |
| 2 | + |
| 3 | +This project uses GitHub Actions with PyPI's trusted publishers for secure, automated publishing. |
| 4 | + |
| 5 | +## Setup Instructions |
| 6 | + |
| 7 | +### 1. Configure PyPI Trusted Publisher |
| 8 | + |
| 9 | +Go to https://pypi.org/manage/project/googleapiutils2/settings/publishing/ and add a new GitHub publisher: |
| 10 | + |
| 11 | +- **Owner**: mkbabb (or your GitHub username/org) |
| 12 | +- **Repository name**: googleapiutils2 |
| 13 | +- **Workflow name**: publish.yml |
| 14 | +- **Environment name**: release (recommended for security) |
| 15 | + |
| 16 | +### 2. Configure TestPyPI Trusted Publisher (Optional) |
| 17 | + |
| 18 | +For testing, configure the same on https://test.pypi.org/: |
| 19 | + |
| 20 | +- **Owner**: mkbabb |
| 21 | +- **Repository name**: googleapiutils2 |
| 22 | +- **Workflow name**: test-publish.yml |
| 23 | +- **Environment name**: (leave empty for test) |
| 24 | + |
| 25 | +### 3. Create GitHub Environment (Recommended) |
| 26 | + |
| 27 | +In your GitHub repository settings: |
| 28 | + |
| 29 | +1. Go to Settings → Environments |
| 30 | +2. Create a new environment called "release" |
| 31 | +3. Add protection rules: |
| 32 | + - Required reviewers (optional) |
| 33 | + - Restrict deployment branches to main/master |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +### Automatic Publishing |
| 38 | + |
| 39 | +1. Create a new release on GitHub |
| 40 | +2. The workflow will automatically: |
| 41 | + - Build the package with UV |
| 42 | + - Publish to PyPI using trusted publishing |
| 43 | + |
| 44 | +### Manual Publishing |
| 45 | + |
| 46 | +Run the workflow manually from Actions tab → Publish to PyPI → Run workflow |
| 47 | + |
| 48 | +### Test Publishing |
| 49 | + |
| 50 | +Every push to master/main automatically publishes to TestPyPI for testing. |
| 51 | + |
| 52 | +## Local Publishing (Emergency Only) |
| 53 | + |
| 54 | +If GitHub Actions fails, you can publish locally: |
| 55 | + |
| 56 | +```bash |
| 57 | +# Build |
| 58 | +uv build |
| 59 | + |
| 60 | +# Publish with API token |
| 61 | +uv publish --token <your-token> |
| 62 | +``` |
| 63 | + |
| 64 | +## Benefits of Trusted Publishing |
| 65 | + |
| 66 | +- No API tokens stored in GitHub secrets |
| 67 | +- Automatic OIDC authentication |
| 68 | +- More secure than password/token auth |
| 69 | +- Audit trail in both GitHub and PyPI |
0 commit comments