Skip to content

release

release #1

Workflow file for this run

name: release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.5.0). Leave empty to auto-bump patch version.'
required: false
type: string
bump:
description: 'Version bump type (only used if version is empty)'
required: false
type: choice
default: 'patch'
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
create-tag:
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.compute-tag.outputs.tag }}
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
- id: compute-tag
run: |
if [ -n "${{ inputs.version }}" ]; then
TAG="v${{ inputs.version }}"
else
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
case "${{ inputs.bump }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
TAG="v${MAJOR}.${MINOR}.${PATCH}"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Computed tag: $TAG"
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a ${{ steps.compute-tag.outputs.tag }} -m "Release ${{ steps.compute-tag.outputs.tag }}"
git push origin ${{ steps.compute-tag.outputs.tag }}
goreleaser:
needs: create-tag
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
ref: ${{ needs.create-tag.outputs.tag }}
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}