Skip to content

Improve release workflow #4307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .github/workflows/cd.yml

This file was deleted.

66 changes: 57 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
name: Automated Release
name: Release

on:
schedule:
# Runs at 2:00 AM UTC on the first Saturday of every month
- cron: '0 2 1-7 * 6'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting this part out into a smaller PR in case the rest of this PR takes longer to merge: #4308

workflow_dispatch: # Allow manual triggering of the workflow
# Allow manual triggering of the workflow
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
type: choice
required: true
default: 'patch'
options:
- minor
- patch
ignore_blocks:
description: 'Ignore blocking PRs/issues'
type: boolean
required: true
default: false

jobs:
check-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -30,6 +44,7 @@ jobs:
fi

- name: Check for Blocking Issues/PRs
if: ${{ !inputs.ignore_blocks }}
id: check_blocks
run: |
gh auth setup-git
Expand Down Expand Up @@ -60,18 +75,51 @@ jobs:
- name: Calculate next version
run: |
echo "Latest tag: ${{ env.latest_tag }}"
IFS='.' read -r major minor patch <<< "${{ env.latest_tag }}"
new_minor=$((minor + 1))
new_tag="$major.$new_minor.0"
IFS='.' read -r major minor patch <<< "${env.latest_tag#v}"

if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ "${{ inputs.version_bump }}" == "patch" ]]; 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="v$major.$minor.$patch"
echo "New tag: $new_tag"
echo "new_tag=$new_tag" >> $GITHUB_ENV

# This will trigger a deploy via .github/workflows/cd.yml
- name: Push New 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 ${{ env.new_tag }}
git push origin ${{ env.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x

- name: Run goreleaser
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goreleaser/homebrew now happen sequentially rather than in parallel, because speed is not important and it reduces the chance of issues from one step failing and the other succeeding

Copy link
Owner Author

@jesseduffield jesseduffield Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to confirm whether goreleaser behaves differently if the workflow itself was not triggered from a tag. Likewise with homebrew.

EDIT: Asked about this in the goreleaser repo: goreleaser/goreleaser-action#492

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that this should be fine

uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: v1.17.2
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GITHUB_API_TOKEN}}

- name: Bump Homebrew formula
uses: dawidd6/action-homebrew-bump-formula@v3
with:
token: ${{secrets.GITHUB_API_TOKEN}}
formula: lazygit
tag: ${{env.new_tag}}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.