From 48173df3dc78f9348eedb3796f29ef9e9e5dc584 Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Thu, 22 Aug 2024 17:12:30 +0000
Subject: [PATCH] ci: use goreleaser-cross for goreleaser-check command
(backport #3806) (#3813)
Closes https://github.com/celestiaorg/celestia-app/issues/3805
[goreleaser
v2.2.0](https://github.com/goreleaser/goreleaser/releases/tag/v2.2.0)
deprecated the `name_template` field in favor of `version_template`. Our
goreleaser-check command used a GH action that was using goreleaser
v2.2.0 so we fixed the deprecation in
https://github.com/celestiaorg/celestia-app/pull/3797 but the make
prebuilt-binary command uses goreleaser-cross which was using a previous
version of goreleaser that fails for the new field.
This PR updates the goreleaser-check command to use the goreleaser-cross
Docker image so that the check command and prebuilt-binary command uses
the same version.
Note: we'll need to update `name_template` to `version_template` when we
upgrade to Go 1.23.0 because that will use goreleaser-cross 1.23.0 which
bumped to goreleaser 2.22.0. See
https://github.com/goreleaser/goreleaser-cross/pull/77
This is an
automatic backport of pull request #3806 done by
[Mergify](https://mergify.com).
Co-authored-by: Rootul P
---
.github/workflows/goreleaser.yml | 16 +++++++++++-----
.goreleaser.yaml | 2 +-
Makefile | 17 +++++++++++++++++
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml
index f25d738a65..dd265479e9 100644
--- a/.github/workflows/goreleaser.yml
+++ b/.github/workflows/goreleaser.yml
@@ -9,12 +9,18 @@ jobs:
goreleaser-check:
runs-on: ubuntu-latest
steps:
- - name: checkout
- uses: actions/checkout@v4
- - uses: goreleaser/goreleaser-action@v6
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - run: git fetch --force --tags
+ - uses: actions/setup-go@v5
with:
- version: latest
- args: check
+ go-version-file: 'go.mod'
+ - name: Create .release-env file
+ run: |-
+ echo 'GITHUB_TOKEN=${{secrets.GORELEASER_ACCESS_TOKEN}}' >> .release-env
+ - name: Check the .goreleaser.yaml config file
+ run: make goreleaser-check
goreleaser:
needs: goreleaser-check
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index c8ce5cff64..950143a3f1 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -108,7 +108,7 @@ archives:
checksum:
name_template: "checksums.txt"
snapshot:
- version_template: "{{ incpatch .Version }}-next"
+ name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
diff --git a/Makefile b/Makefile
index d6e8bc2654..1ee024b0dc 100644
--- a/Makefile
+++ b/Makefile
@@ -191,6 +191,23 @@ adr-gen:
@curl -sSL https://raw.githubusercontent.com/celestiaorg/.github/main/adr-template.md > docs/architecture/adr-template.md
.PHONY: adr-gen
+## goreleaser-check: Check the .goreleaser.yaml config file.
+goreleaser-check:
+ @if [ ! -f ".release-env" ]; then \
+ echo "A .release-env file was not found but is required to create prebuilt binaries. This command is expected to be run in CI where a .release-env file exists. If you need to run this command locally to attach binaries to a release, you need to create a .release-env file with a Github token (classic) that has repo:public_repo scope."; \
+ exit 1;\
+ fi
+ docker run \
+ --rm \
+ -e CGO_ENABLED=1 \
+ --env-file .release-env \
+ -v /var/run/docker.sock:/var/run/docker.sock \
+ -v `pwd`:/go/src/$(PACKAGE_NAME) \
+ -w /go/src/$(PACKAGE_NAME) \
+ ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
+ check
+.PHONY: goreleaser-check
+
## prebuilt-binary: Create prebuilt binaries and attach them to GitHub release. Requires Docker.
prebuilt-binary:
@if [ ! -f ".release-env" ]; then \