Skip to content

Bump Version

Bump Version #1

Workflow file for this run

name: Bump Version
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get current version
id: current
run: |
version=$(grep -m1 '^version' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Compute new version
id: next
run: |
IFS='.' read -r major minor patch <<< "${{ steps.current.outputs.version }}"
case "${{ inputs.bump }}" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
echo "version=${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT"
- name: Update pyproject.toml
run: |
sed -i 's/^version = ".*"/version = "${{ steps.next.outputs.version }}"/' pyproject.toml
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.next.outputs.version }}"
git tag "v${{ steps.next.outputs.version }}"
- name: Push
run: |
git push origin HEAD
git push origin "v${{ steps.next.outputs.version }}"