From c14a0f1101db3f593700eaa77925d36c05596223 Mon Sep 17 00:00:00 2001 From: Randy Westergren Date: Sun, 2 Aug 2026 20:27:41 -0400 Subject: [PATCH] Automate version tags with workflow dispatch --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..17e96da --- /dev/null +++ b/.github/workflows/release.yml @@ -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