Skip to content

Commit

Permalink
internal/ci: fix goreleaser when using gomod.proxy
Browse files Browse the repository at this point in the history
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í <[email protected]>
Change-Id: I2e65a706601c65e7219c5822727b650fe4225461
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1176868
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Paul Jolly <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Feb 21, 2024
1 parent 3b9da48 commit d779310
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/ci/goreleaser/goreleaser.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}' | _
Expand Down

0 comments on commit d779310

Please sign in to comment.