|
| 1 | +# GitHub Workflows |
| 2 | + |
| 3 | +This project uses three GitHub Actions workflows to automate testing, security scanning, and releases. |
| 4 | + |
| 5 | +## Test Workflow |
| 6 | + |
| 7 | +**File:** `.github/workflows/test.yml` |
| 8 | + |
| 9 | +**Triggers:** |
| 10 | +- Push to any branch |
| 11 | +- Pull request to `main` |
| 12 | + |
| 13 | +**Purpose:** Runs the full test suite using tox across multiple Python versions (3.10, 3.11, 3.12, 3.13). This includes pytest, ruff linting, mypy type checking, and bandit security analysis. |
| 14 | + |
| 15 | +**Requirements:** None. This workflow uses only public GitHub Actions and requires no secrets. |
| 16 | + |
| 17 | +## Security Scan Workflow |
| 18 | + |
| 19 | +**File:** `.github/workflows/security-scan.yaml` |
| 20 | + |
| 21 | +**Triggers:** |
| 22 | +- Scheduled: Every Monday at 9:00 AM UTC |
| 23 | +- Manual dispatch (can be triggered from any branch) |
| 24 | + |
| 25 | +**Purpose:** Performs CVE vulnerability scanning on the latest published release using pip-audit via tox. The workflow fetches the latest release version from GitHub and scans it for known vulnerabilities. |
| 26 | + |
| 27 | +**Requirements:** None. Uses only the default `GITHUB_TOKEN` with read permissions. |
| 28 | + |
| 29 | +## Release Workflow |
| 30 | + |
| 31 | +**File:** `.github/workflows/release.yaml` |
| 32 | + |
| 33 | +**Triggers:** |
| 34 | +- Manual dispatch only |
| 35 | + |
| 36 | +**Purpose:** Automates semantic versioning and publishing. The workflow: |
| 37 | +1. Analyzes commits using [semantic-release](https://semantic-release.gitbook.io/) to determine the next version |
| 38 | +2. Creates a GitHub release with changelog |
| 39 | +3. Updates version in `pyproject.toml` |
| 40 | +4. Builds and publishes the package to PyPI |
| 41 | + |
| 42 | +**Requirements:** |
| 43 | +- `SEMANTIC_RELEASE_TOKEN` - GitHub Personal Access Token with `repo` write permissions |
| 44 | +- `PYPI_API_TOKEN` - PyPI API token for package publishing |
| 45 | + |
| 46 | +**Prerequisites:** Commits must follow the [Conventional Commits](https://www.conventionalcommits.org/) format for semantic-release to determine version bumps: |
| 47 | +- `fix:` - Patch release (0.0.x) |
| 48 | +- `feat:` - Minor release (0.x.0) |
| 49 | +- `feat!:` or `BREAKING CHANGE:` - Major release (x.0.0) |
| 50 | + |
| 51 | +## Setting Up Secrets |
| 52 | + |
| 53 | +To configure the required secrets for the release workflow: |
| 54 | + |
| 55 | +### SEMANTIC_RELEASE_TOKEN |
| 56 | + |
| 57 | +1. Go to GitHub **Settings** > **Developer settings** > **Personal access tokens** > **Tokens (classic)** |
| 58 | +2. Click **Generate new token (classic)** |
| 59 | +3. Give it a descriptive name (e.g., "semantic-release") |
| 60 | +4. Select the `repo` scope (full control of private repositories) |
| 61 | +5. Click **Generate token** and copy the token |
| 62 | +6. In your repository, go to **Settings** > **Secrets and variables** > **Actions** |
| 63 | +7. Click **New repository secret** |
| 64 | +8. Name: `SEMANTIC_RELEASE_TOKEN` |
| 65 | +9. Value: Paste the token |
| 66 | +10. Click **Add secret** |
| 67 | + |
| 68 | +### PYPI_API_TOKEN |
| 69 | + |
| 70 | +1. Log in to [PyPI](https://pypi.org/) |
| 71 | +2. Go to **Account settings** > **API tokens** |
| 72 | +3. Click **Add API token** |
| 73 | +4. Give it a descriptive name and scope it to your project (recommended) or all projects |
| 74 | +5. Click **Create token** and copy the token |
| 75 | +6. In your repository, go to **Settings** > **Secrets and variables** > **Actions** |
| 76 | +7. Click **New repository secret** |
| 77 | +8. Name: `PYPI_API_TOKEN` |
| 78 | +9. Value: Paste the token (starts with `pypi-`) |
| 79 | +10. Click **Add secret** |
0 commit comments