jesseduffield.lazygit/.github/workflows/release.yml
Stefan Haller bd8c06ddc0 Rename version_bump options to be extra clear
I keep getting slightly confused as to which is which, so make this
extra clear.

While at it, change the default to minor, this is the option that is
more often used now that we don't have regular scheduled releases any
more.
2026-07-15 13:23:11 +02:00

175 lines
5.3 KiB
YAML

name: Release
on:
# schedule:
# # Runs at 8:00 AM UTC on every Saturday
# # We'll check below if it's the first Saturday of the month, and fail if not
# - cron: '0 8 * * 6'
# Allow manual triggering of the workflow
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
type: choice
required: true
default: 'minor (normal)'
options:
- minor (normal)
- patch (hotfix)
branch:
description: 'Branch to release from'
type: string
required: true
default: 'master'
ignore_blocks:
description: 'Ignore blocking PRs/issues'
type: boolean
required: true
default: false
defaults:
run:
shell: bash
jobs:
check-and-release:
runs-on: ubuntu-latest
steps:
- name: Check for correct repository
if: ${{ github.event_name != 'workflow_dispatch' && github.repository != 'stefanhaller/lazygit' }}
run: |
echo "Should only run in the stefanhaller/lazygit repository"
exit 1
- name: Check for first Saturday of the month
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
if (( $(date +%e) > 7 )); then
echo "This is not the first Saturday of the month"
exit 1
fi
- name: Checkout Code
uses: actions/checkout@v7
with:
repository: jesseduffield/lazygit
ref: ${{ inputs.branch }}
token: ${{ secrets.LAZYGIT_RELEASE_PAT }}
fetch-depth: 0
- name: Get Latest Tag
run: |
latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0")
if ! [[ $latest_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Tag format is invalid. Expected format: vX.X.X"
exit 1
fi
echo "Latest tag: $latest_tag"
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
- name: Check for changes since last release
env:
LATEST_TAG: ${{ env.latest_tag }}
run: |
if [ -z "$(git diff --name-only "$LATEST_TAG")" ]; then
echo "No changes detected since last release"
exit 1
fi
- name: Check that docs and schema are up to date
run: |
if diff -r -q docs docs-master > /dev/null && diff -r -q schema schema-master > /dev/null; then
echo "Docs and schema are up to date."
else
echo "Docs or schema are out of date. Please run 'scripts/update_docs_for_release.sh' and make a PR."
exit 1
fi
- name: Check for Blocking Issues/PRs
if: ${{ !inputs.ignore_blocks }}
id: check_blocks
run: |
gh auth setup-git
gh auth status
echo "Checking for blocking issues and PRs..."
# Check for blocking issues
blocking_issues=$(gh issue list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number))"')
# Check for blocking PRs
blocking_prs=$(gh pr list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number)) (PR)"')
# Combine the results
blocking_items="$blocking_issues"$'\n'"$blocking_prs"
# Remove empty lines
blocking_items=$(echo "$blocking_items" | grep . || true)
if [ -n "$blocking_items" ]; then
echo "Blocking issues/PRs detected:"
echo "$blocking_items"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.LAZYGIT_RELEASE_PAT }}
- name: Calculate next version
env:
LATEST_TAG: ${{ env.latest_tag }}
EVENT_NAME: ${{ github.event_name }}
VERSION_BUMP: ${{ inputs.version_bump }}
run: |
echo "Latest tag: $LATEST_TAG"
IFS='.' read -r major minor patch <<< "$LATEST_TAG"
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
if [[ "$VERSION_BUMP" == "patch (hotfix)" ]]; then
patch=$((patch + 1))
else
minor=$((minor + 1))
patch=0
fi
else
# Default behavior for scheduled runs
minor=$((minor + 1))
patch=0
fi
new_tag="$major.$minor.$patch"
if ! [[ $new_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: New tag's format is invalid. Expected format: vX.X.X"
exit 1
fi
echo "New tag: $new_tag"
echo "new_tag=$new_tag" >> $GITHUB_ENV
- name: Create and Push Tag
env:
NEW_TAG: ${{ env.new_tag }}
GITHUB_TOKEN: ${{ secrets.LAZYGIT_RELEASE_PAT }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$NEW_TAG" -a -m "Release $NEW_TAG"
git push origin "refs/tags/$NEW_TAG"
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: 1.25.x
- name: Run goreleaser
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
distribution: goreleaser
version: v2
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.LAZYGIT_RELEASE_PAT}}