Skip to content

Commit

Permalink
chore: build a specific linux target with CGO_ENABLED=0 (mrparkers#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
Floby authored and Tom Rutsaert committed Jun 25, 2019
1 parent 90d1278 commit ed5debc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions scripts/release-targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"os": "linux",
"platform": "amd64"
},
{
"os": "linux",
"platform": "amd64",
"static": true
},
{
"os": "windows",
"platform": "amd64"
Expand Down

0 comments on commit ed5debc

Please sign in to comment.