From 1a17ab0f794b73c83d4ab9f061343844dac956fc Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 3 Jul 2024 14:20:20 +0200 Subject: [PATCH 1/3] Use different Go cache key for goreleaser jobs The goreleaser jobs perform a cross-platform build of the main binary without test files and as such can (should) use a different object cache. --- .github/workflows/release-snapshot.yml | 15 +++++++++++++-- .github/workflows/release.yml | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index bd89417e21..2e9e477c0b 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -1,6 +1,9 @@ name: release-snapshot on: + pull_request: + types: [opened, synchronize] + push: branches: - "main" @@ -23,13 +26,21 @@ jobs: with: go-version: 1.21.x + # The default cache key for this action considers only the `go.sum` file. + # We include .goreleaser.yaml here to differentiate from the cache used by the push action + # that runs unit tests. This job produces and uses a different cache. + cache-dependency-path: | + go.sum + .goreleaser.yml + - name: Hide snapshot tag to outsmart GoReleaser run: git tag -d snapshot || true - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + id: releaser + uses: goreleaser/goreleaser-action@v6 with: - version: latest + version: ~> v2 args: release --snapshot --skip docker - name: Upload macOS binaries diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bde5b377bd..591b2e5fce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,13 @@ jobs: with: go-version: 1.21.x + # The default cache key for this action considers only the `go.sum` file. + # We include .goreleaser.yaml here to differentiate from the cache used by the push action + # that runs unit tests. This job produces and uses a different cache. + cache-dependency-path: | + go.sum + .goreleaser.yml + # Log into the GitHub Container Registry. The goreleaser action will create # the docker images and push them to the GitHub Container Registry. - uses: "docker/login-action@v3" From 041bb46a16ec8189bcc7b7c9bd05352c87b38512 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 3 Jul 2024 14:28:13 +0200 Subject: [PATCH 2/3] Fix file name --- .github/workflows/release-snapshot.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index 2e9e477c0b..87db7e73c4 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -31,7 +31,7 @@ jobs: # that runs unit tests. This job produces and uses a different cache. cache-dependency-path: | go.sum - .goreleaser.yml + .goreleaser.yaml - name: Hide snapshot tag to outsmart GoReleaser run: git tag -d snapshot || true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 591b2e5fce..5079c3681b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: # that runs unit tests. This job produces and uses a different cache. cache-dependency-path: | go.sum - .goreleaser.yml + .goreleaser.yaml # Log into the GitHub Container Registry. The goreleaser action will create # the docker images and push them to the GitHub Container Registry. From c17cf1c9af2ad3276e8fd04a2828492c5449548c Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 3 Jul 2024 14:30:35 +0200 Subject: [PATCH 3/3] Don't run release-snapshot job on PRs --- .github/workflows/release-snapshot.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index 87db7e73c4..1dafe1c7c1 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -1,9 +1,6 @@ name: release-snapshot on: - pull_request: - types: [opened, synchronize] - push: branches: - "main"