CI/CD (GitHub Actions)¶
Bumpwright integrates easily with GitHub Actions. The following workflows demonstrate common setups:
Automatically apply a version bump on pushes to your main branch.
Suggest the next semantic version in pull requests.
Publish a release and package on tag push.
Place the selected file in .github/workflows
to use it.
Workflows that create commits or tags require permissions: contents: write
and authenticate using the default GITHUB_TOKEN
. When referencing the
current commit, ${{ github.sha }}
expands to the workflow’s commit SHA.
Automatic version bump on push¶
The bumpwright-auto-bump.yml
workflow updates your project version and
changelog whenever new commits land on main
or master
. It runs
bumpwright bump --changelog CHANGELOG.md --commit --tag --format md
to
commit the change and create a matching tag.
name: bumpwright auto bump
on:
push:
branches:
- main
- master
permissions:
contents: write
concurrency:
group: bumpwright-auto-bump-${{ github.ref }}
cancel-in-progress: false
jobs:
bump:
# Prevent re-trigger loops from bot commits
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout (full history + tags)
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install project
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Configure git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version, update changelog, commit & tag
run: |
bumpwright bump --changelog CHANGELOG.md --commit --tag --format md
- name: Push commit and tags
run: |
git push origin HEAD:${{ github.ref_name }}
git push --tags
Download the file: bumpwright-auto-bump.yml
.
Pull request check¶
The bumpwright-check.yml
workflow runs Bumpwright in read-only mode to
suggest the next version. Trigger it manually with the workflow_dispatch
event, or adapt it to run on pull requests.
name: bumpwright version check
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
decide:
runs-on: ubuntu-latest
steps:
- name: Checkout (full history + tags)
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install bumpwright
run: pip install --upgrade bumpwright
- name: Compute suggestion (json & md)
id: suggest
run: |
bumpwright decide --format json > .bump.json
bumpwright decide --format md > .bump.md
python - <<'PY'
import json, os
j=json.load(open(".bump.json"))
suggested=j.get("suggested") or j.get("bump") or ""
next_version=j.get("next_version") or ""
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"suggested={suggested}\n")
f.write(f"next_version={next_version}\n")
PY
- name: Add summary to job
run: |
{
echo "### Bumpwright suggestion"; echo;
cat .bump.md
} >> "$GITHUB_STEP_SUMMARY"
- name: Comment on PR (sticky)
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync('.bump.md', 'utf8');
const marker = '<!-- bumpwright-suggestion -->';
const payload = body + '\n\n' + marker;
const {owner, repo} = context.repo;
const issue_number = context.issue.number;
const { data: comments } = await github.rest.issues.listComments({
owner, repo, issue_number
});
const prev = comments.find(c => c.user.type === 'Bot' && c.body && c.body.includes(marker));
if (prev) {
await github.rest.issues.updateComment({
owner, repo, comment_id: prev.id, body: payload
});
} else {
await github.rest.issues.createComment({
owner, repo, issue_number, body: payload
});
}
Download the file: bumpwright-check.yml
.
Release & publish on tag¶
The bumpwright-release.yml
workflow builds wheels and an sdist, uploads
them to PyPI using Trusted Publishing, and creates a GitHub Release whenever a
tag prefixed with v
is pushed.
name: bumpwright release & publish
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout (full history + tags)
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Build package
run: |
python -m pip install --upgrade pip
pip install build
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: dist/*
Download the file: bumpwright-release.yml
.
Keyword-triggered bump¶
The bumpwright-keyword-bump.yml
workflow applies a version bump only when
any commit message in the push contains the [bump]
marker. This lets you
control releases through commit messages while ignoring other changes.
name: bumpwright keyword bump
on:
push:
branches:
- main
- master
permissions:
contents: write
concurrency:
group: bumpwright-keyword-bump-${{ github.ref }}
cancel-in-progress: false
jobs:
bump:
# Run only if any commit message contains the [bump] marker
if: |
github.actor != 'github-actions[bot]' &&
contains(join(github.event.commits.*.message, ' '), '[bump]')
runs-on: ubuntu-latest
steps:
- name: Checkout (full history + tags)
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
- name: Install bumpwright
run: |
python -m pip install --upgrade pip
pip install bumpwright
- name: Configure git author
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version and update changelog
run: |
bumpwright bump --changelog CHANGELOG.md --commit --tag
- name: Push commit and tags
run: |
git push origin HEAD:${{ github.ref_name }}
git push --tags
Download the file: bumpwright-keyword-bump.yml
.