|
| 1 | +# GitHub Actions Workflows for PyPI Publishing |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for automatically publishing the diffrays package to PyPI. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### 1. `publish.yml` - Production PyPI Publishing |
| 8 | +- **Triggers**: |
| 9 | + - When a GitHub release is published |
| 10 | + - Manual trigger via GitHub Actions UI |
| 11 | +- **Purpose**: Publishes the package to the official PyPI repository |
| 12 | +- **Required Secret**: `PYPI_API_TOKEN` |
| 13 | + |
| 14 | +### 2. `testpypi.yml` - TestPyPI Publishing |
| 15 | +- **Triggers**: |
| 16 | + - Push to `main` or `develop` branches |
| 17 | + - Manual trigger via GitHub Actions UI |
| 18 | +- **Purpose**: Publishes the package to TestPyPI for testing |
| 19 | +- **Required Secret**: `TEST_PYPI_API_TOKEN` |
| 20 | + |
| 21 | +## Setup Instructions |
| 22 | + |
| 23 | +### For Production PyPI Publishing: |
| 24 | + |
| 25 | +1. **Create PyPI API Token**: |
| 26 | + - Go to [PyPI](https://pypi.org) and log in |
| 27 | + - Navigate to Account Settings → API tokens |
| 28 | + - Create a new API token (scope: "Entire account" or project-specific) |
| 29 | + - Copy the token (starts with `pypi-`) |
| 30 | + |
| 31 | +2. **Add GitHub Secret**: |
| 32 | + - Go to your GitHub repository |
| 33 | + - Settings → Secrets and variables → Actions |
| 34 | + - Click "New repository secret" |
| 35 | + - Name: `PYPI_API_TOKEN` |
| 36 | + - Value: Your PyPI API token |
| 37 | + |
| 38 | +3. **Publishing Process**: |
| 39 | + - Update version in `pyproject.toml` |
| 40 | + - Commit and push changes |
| 41 | + - Create a GitHub release with the same version number |
| 42 | + - The workflow will automatically publish to PyPI |
| 43 | + |
| 44 | +### For TestPyPI Publishing: |
| 45 | + |
| 46 | +1. **Create TestPyPI Account**: |
| 47 | + - Go to [test.pypi.org](https://test.pypi.org) |
| 48 | + - Create an account (can be same as PyPI account) |
| 49 | + |
| 50 | +2. **Create TestPyPI API Token**: |
| 51 | + - Log in to TestPyPI |
| 52 | + - Go to Account Settings → API tokens |
| 53 | + - Create a new API token |
| 54 | + - Copy the token |
| 55 | + |
| 56 | +3. **Add GitHub Secret**: |
| 57 | + - Add `TEST_PYPI_API_TOKEN` secret in GitHub repository settings |
| 58 | + - Value: Your TestPyPI API token |
| 59 | + |
| 60 | +## Usage |
| 61 | + |
| 62 | +### Manual Publishing |
| 63 | +Both workflows support manual triggering: |
| 64 | +1. Go to GitHub repository → Actions tab |
| 65 | +2. Select the desired workflow |
| 66 | +3. Click "Run workflow" |
| 67 | + |
| 68 | +### Version Management |
| 69 | +- Update the version in `pyproject.toml` before creating a release |
| 70 | +- The version in the release tag should match the version in `pyproject.toml` |
| 71 | +- Example: If `pyproject.toml` has `version = "1.6"`, create a release with tag `v1.6` |
| 72 | + |
| 73 | +## Security Notes |
| 74 | +- Never commit API tokens to the repository |
| 75 | +- Use repository secrets for storing sensitive information |
| 76 | +- API tokens provide better security than username/password authentication |
0 commit comments