Use the host target for source-built release tools
This commit is contained in:
@@ -321,6 +321,7 @@ func TestWoodpeckerSourceDeliveryTemplateSelfBootstraps(t *testing.T) {
|
||||
commit := pushTaggedCLIRepository(t, repository)
|
||||
goDir, goLog := installGoBootstrapShim(t)
|
||||
env := templateEnvironment(repository, commit, goDir, goLog)
|
||||
env["GOOS"], env["GOARCH"] = foreignTarget()
|
||||
useSyntheticModuleProxy(t, env, proxy.URL)
|
||||
proxyRequests.Store(0)
|
||||
env["CI_COMMIT_SHA"] = strings.Repeat("0", len(commit))
|
||||
@@ -343,6 +344,9 @@ func TestWoodpeckerSourceDeliveryTemplateSelfBootstraps(t *testing.T) {
|
||||
t.Fatalf("self-bootstrapped command arguments = %q", output)
|
||||
}
|
||||
log := readWoodpeckerFixtureFile(t, goLog)
|
||||
if !strings.Contains(log, "build-target="+runtime.GOOS+"/"+runtime.GOARCH) {
|
||||
t.Fatalf("source build did not use host target: %s", log)
|
||||
}
|
||||
if !strings.Contains(log, "GOWORK=off GOTOOLCHAIN=local") || !strings.Contains(log, "build -mod=readonly -o ") || !strings.Contains(log, "./cmd/releasekit") {
|
||||
t.Fatalf("self-bootstrap Go command = %q", log)
|
||||
}
|
||||
@@ -427,6 +431,7 @@ func installGoBootstrapShim(t *testing.T) (string, string) {
|
||||
shim := `#!/bin/sh
|
||||
printf 'cwd=%s GOWORK=%s GOTOOLCHAIN=%s %s\n' "$PWD" "$GOWORK" "$GOTOOLCHAIN" "$*" >> "$RELEASEKIT_GO_LOG"
|
||||
case " $* " in *" -deps "*) printf 'target=%s/%s\n' "$GOOS" "$GOARCH" >> "$RELEASEKIT_GO_LOG" ;; esac
|
||||
if [ "$1" = build ]; then printf 'build-target=%s/%s\n' "$GOOS" "$GOARCH" >> "$RELEASEKIT_GO_LOG"; fi
|
||||
"$RELEASEKIT_REAL_GO" "$@"
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ] && [ "$1" = "tool" ] && [ -n "${RELEASEKIT_SUM_LOG:-}" ]; then
|
||||
|
||||
@@ -193,10 +193,16 @@ immutable version from its tag:
|
||||
```sh
|
||||
git fetch origin "refs/tags/vX.Y.Z:refs/tags/vX.Y.Z"
|
||||
git checkout --detach "vX.Y.Z"
|
||||
GOTOOLCHAIN=local go mod download
|
||||
mkdir -p .releasekit/bin
|
||||
GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off go build -o .releasekit/bin/releasekit ./cmd/releasekit
|
||||
.releasekit/bin/releasekit deliver "vX.Y.Z"
|
||||
(
|
||||
set -e
|
||||
releasekit_host_os=$(GOTOOLCHAIN=local go env GOHOSTOS)
|
||||
releasekit_host_arch=$(GOTOOLCHAIN=local go env GOHOSTARCH)
|
||||
export GOOS="$releasekit_host_os" GOARCH="$releasekit_host_arch"
|
||||
GOTOOLCHAIN=local go mod download
|
||||
mkdir -p .releasekit/bin
|
||||
GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off go build -o .releasekit/bin/releasekit ./cmd/releasekit
|
||||
.releasekit/bin/releasekit deliver "vX.Y.Z"
|
||||
)
|
||||
```
|
||||
|
||||
For an older tag whose CLI predates `token_file`, supply the token through its
|
||||
|
||||
@@ -70,6 +70,8 @@ checks in Stage 6.
|
||||
|
||||
## Stage 3: Normalize source-built launchers
|
||||
|
||||
**Completed.**
|
||||
|
||||
1. Apply the same recipe in the [maintainer launcher](../../scripts/release)
|
||||
before building and executing ReleaseKit. Prefix the two queries with
|
||||
`GOTOOLCHAIN=local` to match its existing build. Preserve usage checking,
|
||||
|
||||
@@ -30,6 +30,9 @@ steps:
|
||||
trap 'rm -rf "$${bootstrap_dir}"' EXIT
|
||||
export GOWORK=off
|
||||
export GOTOOLCHAIN=local
|
||||
releasekit_host_os=$(go env GOHOSTOS) || exit $?
|
||||
releasekit_host_arch=$(go env GOHOSTARCH) || exit $?
|
||||
export GOOS="$${releasekit_host_os}" GOARCH="$${releasekit_host_arch}"
|
||||
go build -mod=readonly -o "$${bootstrap_dir}/releasekit" ./cmd/releasekit
|
||||
"$${bootstrap_dir}/releasekit" ci-deliver \
|
||||
--repo "$${CI_WORKSPACE}" \
|
||||
|
||||
@@ -6,6 +6,9 @@ if [ "$#" -ne 1 ]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
releasekit_host_os=$(GOTOOLCHAIN=local go env GOHOSTOS) || exit $?
|
||||
releasekit_host_arch=$(GOTOOLCHAIN=local go env GOHOSTARCH) || exit $?
|
||||
export GOOS="$releasekit_host_os" GOARCH="$releasekit_host_arch"
|
||||
mkdir -p .releasekit/bin
|
||||
GOTOOLCHAIN=local go build -o .releasekit/bin/releasekit ./cmd/releasekit
|
||||
exec .releasekit/bin/releasekit publish "$1"
|
||||
|
||||
Reference in New Issue
Block a user