31 lines
1.1 KiB
Bash
Executable File
31 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
#
|
|
# Cross-compile terraform-provider-threshold for linux/darwin/windows on
|
|
# amd64/arm64 and zip each binary in the layout Terraform expects:
|
|
# dist/terraform-provider-threshold_<version>_<os>_<arch>.zip
|
|
# containing the single file terraform-provider-threshold_v<version>[.exe].
|
|
#
|
|
# Usage: scripts/build-release.sh [version] [outdir]
|
|
set -euo pipefail
|
|
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
version="${1:-$(cat "$root/version/VERSION")}"
|
|
out="${2:-$root/dist}"
|
|
mkdir -p "$out"
|
|
|
|
for os in linux darwin windows; do
|
|
for arch in amd64 arm64; do
|
|
ext=""; [ "$os" = windows ] && ext=".exe"
|
|
bin="terraform-provider-threshold_v${version}${ext}"
|
|
tmp="$(mktemp -d)"
|
|
echo "==> ${os}/${arch}"
|
|
(cd "$root" && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
|
|
go build -trimpath -ldflags "-s -w" -o "$tmp/$bin" .)
|
|
(cd "$tmp" && zip -q -j "$out/terraform-provider-threshold_${version}_${os}_${arch}.zip" "$bin")
|
|
rm -rf "$tmp"
|
|
done
|
|
done
|
|
(cd "$out" && sha256sum ./*.zip > "terraform-provider-threshold_${version}_SHA256SUMS")
|
|
echo "Artifacts in $out"
|