From f0e28ea4c7b5489a877548b9837cf05d30a28ecb Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Fri, 21 Oct 2022 00:15:37 +0530 Subject: [PATCH] Use .exe when building for Windows (#1251) ## Description Use .exe when building for Windows. Adds quoting for paths. ## Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Test - [x] :computer: CI/Deployment - [x] :hamster: Trivial/Minor ## Issue(s) * # ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- build/build.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/build/build.sh b/build/build.sh index f0273122c..9f1237882 100755 --- a/build/build.sh +++ b/build/build.sh @@ -58,24 +58,27 @@ if [ "$MODE" == "binary" ]; then printf "Building for %s...\r" "$platform" docker run --rm \ - --mount type=bind,src=${ROOT},dst="/app" \ - --mount type=bind,src=${CORSO_BUILD_CACHE},dst=${CORSO_BUILD_CACHE} \ - --env GOMODCACHE=${CORSO_BUILD_CACHE}/mod --env GOCACHE=${CORSO_BUILD_CACHE}/cache \ + --mount type=bind,src="${ROOT}",dst="/app" \ + --mount type=bind,src="${CORSO_BUILD_CACHE}",dst="${CORSO_BUILD_CACHE}" \ + --env GOMODCACHE="${CORSO_BUILD_CACHE}/mod" --env GOCACHE="${CORSO_BUILD_CACHE}/cache" \ --env GOOS=${GOOS} --env GOARCH=${GOARCH} \ --workdir "/app/src" \ golang:${GOVER} \ go build -o corso -ldflags "${CORSO_BUILD_LDFLAGS}" - mkdir -p ${ROOT}/bin/${GOOS}-${GOARCH} - mv ${ROOT}/src/corso ${ROOT}/bin/${GOOS}-${GOARCH}/corso - echo Corso $platform binary available in ${ROOT}/bin/${GOOS}-${GOARCH}/corso + OUTFILE="corso" + [ "$GOOS" == "windows" ] && OUTFILE="corso.exe" + + mkdir -p "${ROOT}/bin/${GOOS}-${GOARCH}" + mv "${ROOT}/src/corso" "${ROOT}/bin/${GOOS}-${GOARCH}/${OUTFILE}" + echo Corso $platform binary available in "${ROOT}/bin/${GOOS}-${GOARCH}/${OUTFILE}" done else echo Building "$TAG" image for "$PLATFORMS" docker buildx build --tag ${TAG} \ --platform ${PLATFORMS} \ - --file ${ROOT}/build/Dockerfile \ + --file "${ROOT}/build/Dockerfile" \ --build-arg CORSO_BUILD_LDFLAGS="$CORSO_BUILD_LDFLAGS" \ - --load ${ROOT} + --load "${ROOT}" echo Built container image "$TAG" fi