Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
workflow_dispatch:
inputs:
bump:
description: "Version bump"
type: choice
options: [patch, minor, major]
default: patch

permissions:
contents: write

jobs:
tag-and-release:
runs-on: ubuntu-latest
steps:
- name: Ensure release runs from main
if: github.ref != 'refs/heads/main'
run: |
echo "Releases must be cut from the main branch."
exit 1

- uses: actions/checkout@v4
with:
fetch-depth: 0 # need tags to find the latest

- name: Compute next version
id: ver
run: |
latest=$(git tag --list 'v*' --sort=-v:refname | head -n1)
latest=${latest:-v0.0.0}
IFS=. read -r major minor patch <<< "${latest#v}"
case "${{ inputs.bump }}" in
major) major=$((major+1)); minor=0; patch=0 ;;
minor) minor=$((minor+1)); patch=0 ;;
patch) patch=$((patch+1)) ;;
esac
echo "tag=v$major.$minor.$patch" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.ver.outputs.tag }}" \
--title "${{ steps.ver.outputs.tag }}" \
--generate-notes
Loading