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