Minimal Workflow¶
A simple two-job workflow for automated releases.
Complete Workflow¶
.github/workflows/release.yml
name: Release
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
# Create release PR on every push (except release commits)
release-pr:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: mikeleppane/releasio@v2
with:
command: release-pr
github-token: ${{ secrets.GITHUB_TOKEN }}
# Release when PR is merged (detected by commit message)
release:
if: startsWith(github.event.head_commit.message, 'chore(release):')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: mikeleppane/releasio@v2
with:
command: release
github-token: ${{ secrets.GITHUB_TOKEN }}
How It Works¶
%%{init: {'theme': 'neutral'}}%%
graph TD
A[Push to main] --> B{Release commit?}
B -->|No| C[release-pr job]
B -->|Yes| D[release job]
C --> E[Create/Update PR]
D --> F[Tag + Publish]
Flow¶
- Push feature commits →
release-prcreates/updates a release PR - Merge the PR → Creates a
chore(release):commit - Release commit detected →
releasejob creates tag and publishes
Key Points¶
fetch-depth: 0¶
Required for releasio to access full git history:
Commit Detection¶
The workflow uses commit message prefix to detect release PRs:
# Skip release PR creation for release commits
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
# Only release on release commits
if: startsWith(github.event.head_commit.message, 'chore(release):')
Permissions¶
All three permissions are required:
permissions:
contents: write # Tags and releases
pull-requests: write # PR creation
id-token: write # PyPI trusted publishing
Enabling PR Creation¶
- Go to Settings → Actions → General
- Scroll to "Workflow permissions"
- Enable "Allow GitHub Actions to create and approve pull requests"
Next Steps¶
- Full Workflow - Add manual triggers
- Action Reference - All options
- Trusted Publishing - PyPI OIDC setup