Skip to content

feat: auto-bootstrap, pure-Go statusline, focus-events, spinnerTips #5

feat: auto-bootstrap, pure-Go statusline, focus-events, spinnerTips

feat: auto-bootstrap, pure-Go statusline, focus-events, spinnerTips #5

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
bump:
description: "Version bump level"
required: true
default: minor
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Run tests
run: go test ./...
- name: Determine bump level
id: level
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "level=${{ inputs.bump }}" >> "$GITHUB_OUTPUT"
else
echo "level=patch" >> "$GITHUB_OUTPUT"
fi
- name: Compute next version
id: version
run: |
git fetch --tags --force
LATEST=$(git tag -l 'v[0-9]*' --sort=-v:refname | head -n1)
if [ -z "$LATEST" ]; then
LATEST="v0.0.0"
fi
echo "latest=$LATEST" >> "$GITHUB_OUTPUT"
VERSION="${LATEST#v}"
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
case "${{ steps.level.outputs.level }}" 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 "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "Next version: $NEXT (from $LATEST, bump=${{ steps.level.outputs.level }})"
- name: Generate release notes
id: notes
env:
VERSION: ${{ steps.version.outputs.next }}
PREV: ${{ steps.version.outputs.latest }}
run: |
{
echo "## Install"
echo
echo '```bash'
echo "go install github.com/${{ github.repository }}@$VERSION"
echo '```'
echo
echo "## Changes"
echo
if [ "$PREV" = "v0.0.0" ]; then
git log --pretty=format:'- %s (%h)' | head -n 200
else
git log --pretty=format:'- %s (%h)' "$PREV"..HEAD
fi
} > release-notes.md
echo "Generated notes:"
cat release-notes.md
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create tag
env:
VERSION: ${{ steps.version.outputs.next }}
run: |
git tag -a "$VERSION" -m "Release $VERSION"
git push origin "$VERSION"
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.next }}
run: |
gh release create "$VERSION" \
--title "$VERSION" \
--notes-file release-notes.md