Skip to content

Commit

Permalink
internal/ci: fix goreleaser in non-snapshot mode again
Browse files Browse the repository at this point in the history
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í <[email protected]>
Change-Id: If81984a15c26b797a90616554df8f7f647473afd
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549337
Reviewed-by: Paul Jolly <[email protected]>
Unity-Result: CUEcueckoo <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
(cherry picked from commit 9871d8d)
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/549338
  • Loading branch information
mvdan committed Feb 2, 2023
1 parent ca411de commit 576d0e4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions internal/ci/goreleaser/goreleaser_tool.cue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package goreleaser

import (
"encoding/yaml"
"path"
"strings"
"encoding/yaml"

"tool/file"
"tool/exec"
Expand All @@ -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
}
Expand Down Expand Up @@ -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, " "))
"""
}

Expand All @@ -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
}
}

0 comments on commit 576d0e4

Please sign in to comment.