Parcourir la source

fix(ci): install mtg-multi without GOBIN for cross-compiled release builds

go install refuses to run with GOBIN set when GOOS/GOARCH differ from the host, which failed the linux release build for every non-amd64 platform (386, arm64, armv7, armv6). Let it install into GOPATH/bin instead, where cross-compiled binaries land in a GOOS_GOARCH subdirectory, and locate the binary there. DockerInit.sh keeps GOBIN because buildx runs it under emulation for the target platform, making the install native.
MHSanaei il y a 15 heures
Parent
commit
977fe4b4ea
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 7 2
      .github/workflows/release.yml

+ 7 - 2
.github/workflows/release.yml

@@ -159,11 +159,16 @@ jobs:
           # mtg-multi (MTProto sidecar) is pure Go, so build it from source for the
           # target arch (GOOS/GOARCH/GOARM are already exported above). Its release
           # binaries only cover linux/darwin amd64/arm64; skip s390x/armv5 as before.
+          # go install rejects GOBIN for cross-compiled targets, so let it install
+          # into GOPATH/bin (a GOOS_GOARCH subdir when cross-compiling) and fetch
+          # the binary from there.
           MTG_MULTI_VER="v1.11.0"
           case "${{ matrix.platform }}" in
             amd64|arm64|armv7|armv6|386)
-              CGO_ENABLED=0 GOBIN="$(pwd)" go install -trimpath -ldflags "-s -w" "github.com/dolonet/mtg-multi@${MTG_MULTI_VER}"
-              mv mtg-multi "mtg-linux-${{ matrix.platform }}"
+              CGO_ENABLED=0 go install -trimpath -ldflags "-s -w" "github.com/dolonet/mtg-multi@${MTG_MULTI_VER}"
+              MTG_BIN=$(find "$(go env GOPATH)/bin" -type f -name mtg-multi | head -n1)
+              [ -n "$MTG_BIN" ] || { echo "mtg-multi binary not found under $(go env GOPATH)/bin" >&2; exit 1; }
+              mv "$MTG_BIN" "mtg-linux-${{ matrix.platform }}"
               ;;
           esac
           cd ../..