diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85426e6d5..102000f0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,6 +58,18 @@ jobs: token: ${{ secrets.LAZYGIT_RELEASE_PAT }} fetch-depth: 0 + - name: Check that release.yml is up to date + run: | + # This workflow runs in a fork, but releases jesseduffield/lazygit, so + # its release.yml must match the one on jesseduffield/lazygit's master. + git fetch --quiet "https://github.com/$GITHUB_REPOSITORY" "$GITHUB_WORKFLOW_SHA" + + if ! git diff --quiet "$GITHUB_WORKFLOW_SHA" origin/master -- .github/workflows/release.yml; then + echo "Error: release.yml differs from the one on jesseduffield/lazygit's master." + echo "Update $GITHUB_REPOSITORY from there and run the workflow again." + exit 1 + fi + - name: Get Latest Tag run: | latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0") @@ -149,6 +161,24 @@ jobs: echo "New tag: $new_tag" echo "new_tag=$new_tag" >> $GITHUB_ENV + - name: Get Go version + run: | + # Take the Go version from the go.mod of the code being released, so + # that a patch release from a branch off an older tag is built with + # that branch's Go version, not with master's. + # + # Turn "go 1.26.0" into "1.26.x" so that setup-go installs the latest + # patch release. With go-version-file, it would install exactly 1.26.0. + go_version=$(sed -n 's/^go \([0-9]*\.[0-9]*\).*/\1.x/p' go.mod) + + if ! [[ $go_version =~ ^[0-9]+\.[0-9]+\.x$ ]]; then + echo "Error: Could not read the go version from go.mod" + exit 1 + fi + + echo "Go version: $go_version" + echo "go_version=$go_version" >> $GITHUB_ENV + - name: Create and Push Tag env: NEW_TAG: ${{ env.new_tag }} @@ -162,7 +192,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: ${{ env.go_version }} - name: Run goreleaser uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3