From d779310a04c941d486cbdce2fbe35e2d61278ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 21 Feb 2024 11:24:12 +0000 Subject: [PATCH] internal/ci: fix goreleaser when using gomod.proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We enable gomod.proxy, meaning that `goreleaser release` builds CUE tags by pulling the version through proxy.golang.org, which helps so that our CUE binaries get stamped with the right main module version. This unfortunately broke with a recent change adding `id: main`, which caused the CI build of v0.8.0-alpha.2 to fail: failed to proxy module: exit status 1: go: malformed module path "./cmd/cue": invalid path element "." Paul added the explicit "id" field because otherwise goreleaser complains about duplicate ID strings: found 2 builds with the ID 'cue', please fix your config It should default to the binary name string, so make it that, which fixes the build of v0.8.0-alpha.2 with goreleaser. I verified this with `goreleaser --skip=announce,publish,validate`, which is similar to `goreleaser --snapshot`, but expects a current tag and also does keep gomod.proxy enabled. Leave notes to remind ourselves of the tricky details above. Signed-off-by: Daniel Martí Change-Id: I2e65a706601c65e7219c5822727b650fe4225461 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1176868 TryBot-Result: CUEcueckoo Reviewed-by: Paul Jolly Unity-Result: CUE porcuepine --- internal/ci/goreleaser/goreleaser.cue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/ci/goreleaser/goreleaser.cue b/internal/ci/goreleaser/goreleaser.cue index b8098a26921..a1856913083 100644 --- a/internal/ci/goreleaser/goreleaser.cue +++ b/internal/ci/goreleaser/goreleaser.cue @@ -4,6 +4,9 @@ config: { #latest: bool @tag(latest, type=bool) project_name: "cue" + // Note that gomod.proxy is ignored by `goreleaser release --snapshot`, + // which we use in CI to test the goreleaser config and build, + // as --snapshot is meant for entirely local builds without a git tag. gomod: proxy: true // Template based on common settings @@ -17,7 +20,9 @@ config: { flags: *[ "-trimpath", ] | _ - id: main + // Note that goreleaser says that id defaults to the binary name, + // but it then complains about "cue" being duplicate even though we use "cue" and "cuepls". + id: binary main: string binary: string mod_timestamp: *'{{ .CommitTimestamp }}' | _