diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 295b557..181fd1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,13 @@ on: push: tags: - "v*" + workflow_dispatch: + inputs: + bump: + description: "Version bump" + type: choice + options: [patch, minor, major] + default: patch permissions: contents: write @@ -19,6 +26,27 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 + - name: Bump and push tag + if: github.event_name == 'workflow_dispatch' + run: | + set -euo pipefail + if [ "${GITHUB_REF}" != "refs/heads/master" ]; then + echo "workflow_dispatch must run from master (got ${GITHUB_REF})" >&2 + exit 1 + fi + git fetch --tags + 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 + next="v${major}.${minor}.${patch}" + echo "Bumping ${latest} -> ${next}" + git tag "${next}" + git push origin "${next}" - uses: actions/setup-go@v6 with: go-version: "1.25"