From 576d0e461a990ddcdab9da7a10375a1c6d87a865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 2 Feb 2023 17:26:05 +0000 Subject: [PATCH] internal/ci: fix goreleaser in non-snapshot mode again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://cuelang.org/cl/546931 changed the goreleaser CUE command to use a list instead of a string for the exec.Run arguments. That is a good change, as it makes the list of arguments more explicit, but we introduced a regression where not wanting to use the --snapshot flag meant that we ended up with an empty argument: error: unknown command "" for "goreleaser release" To avoid that problem, use an if comprehension inside the list. For debugging in the future, print the entire list of arguments too. Signed-off-by: Daniel Martí Change-Id: If81984a15c26b797a90616554df8f7f647473afd Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549337 Reviewed-by: Paul Jolly Unity-Result: CUEcueckoo TryBot-Result: CUEcueckoo (cherry picked from commit 9871d8d4dc8a91d1655cf2d08ef4e6276f8e3277) Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549338 --- internal/ci/goreleaser/goreleaser_tool.cue | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/internal/ci/goreleaser/goreleaser_tool.cue b/internal/ci/goreleaser/goreleaser_tool.cue index c18b1d86706..f7ad1d61e7f 100644 --- a/internal/ci/goreleaser/goreleaser_tool.cue +++ b/internal/ci/goreleaser/goreleaser_tool.cue @@ -1,9 +1,9 @@ package goreleaser import ( + "encoding/yaml" "path" "strings" - "encoding/yaml" "tool/file" "tool/exec" @@ -19,11 +19,6 @@ command: release: { let _githubRef = env.GITHUB_REF | "refs/no_ref_kind/not_a_release" // filled when running in CI let _githubRefName = path.Base(_githubRef) - // Only run the full release when running on GitHub actions for a release tag. - // Keep in sync with core.#releaseTagPattern, which is a globbing pattern - // rather than a regular expression. - let snapshot = [ if _githubRef !~ "refs/tags/v.*" {"--snapshot"}, "" ][0] - tempDir: file.MkdirTemp & { path: string } @@ -57,12 +52,23 @@ command: release: { stdout: string } + let goreleaserCmd = [ + "goreleaser", "release", "-f", "-", "--rm-dist", + + // Only run the full release when running on GitHub actions for a release tag. + // Keep in sync with core.#releaseTagPattern, which is a globbing pattern + // rather than a regular expression. + if _githubRef !~ "refs/tags/v.*" { + "--snapshot" + }, + ] + info: cli.Print & { text: """ - snapshot: \(snapshot) latest CUE version: \(latestCUEVersion) git ref: \(_githubRef) release name: \(_githubRefName) + goreleaser cmd: \(strings.Join(goreleaserCmd, " ")) """ } @@ -77,6 +83,6 @@ command: release: { // Run at the root of the module dir: strings.TrimSpace(cueModRoot.stdout) - cmd: ["goreleaser", "release", "-f", "-", "--rm-dist", snapshot] + cmd: goreleaserCmd } }