From 0e36511a9266bc3a64274b235b9150affbc4bf0b Mon Sep 17 00:00:00 2001 From: Florent Jaby Date: Thu, 20 Jun 2019 15:36:52 +0200 Subject: [PATCH] chore: build a specific linux target with CGO_ENABLED=0 (#129) --- scripts/build-release.sh | 14 +++++++++++--- scripts/release-targets.json | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 6006369bc..46eae319d 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -9,12 +9,20 @@ mkdir -p ../artifacts for config in $(cat release-targets.json | jq -rc '.[]'); do os=$(echo ${config} | jq -r '.os') platform=$(echo ${config} | jq -r '.platform') + static=$(echo ${config} | jq -r '.static // false') + linkage='' + if [[ ${static} = 'true' ]]; then + export CGO_ENABLED=0 + linkage='_static' + else + unset CGO_ENABLED + fi - echo "Building for ${os}_${platform}..." + echo "Building for ${os}_${platform}${linkage}..." GOOS=${os} GOARCH=${platform} go build -o terraform-provider-keycloak_v${CIRCLE_TAG} .. - zip terraform-provider-keycloak_v${CIRCLE_TAG}_${os}_${platform}.zip terraform-provider-keycloak_v${CIRCLE_TAG} ../LICENSE - mv terraform-provider-keycloak_v${CIRCLE_TAG}_${os}_${platform}.zip ../artifacts + zip terraform-provider-keycloak_v${CIRCLE_TAG}_${os}_${platform}${linkage}.zip terraform-provider-keycloak_v${CIRCLE_TAG} ../LICENSE + mv terraform-provider-keycloak_v${CIRCLE_TAG}_${os}_${platform}${linkage}.zip ../artifacts rm terraform-provider-keycloak_v${CIRCLE_TAG} done; diff --git a/scripts/release-targets.json b/scripts/release-targets.json index f39470b85..d610b999b 100644 --- a/scripts/release-targets.json +++ b/scripts/release-targets.json @@ -7,6 +7,11 @@ "os": "linux", "platform": "amd64" }, + { + "os": "linux", + "platform": "amd64", + "static": true + }, { "os": "windows", "platform": "amd64"