driftctl/scripts/build.sh

52 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
#
# This script builds the application from source for multiple platforms.
# Inspired from hashicorp/terraform build script
2021-07-15 15:33:35 +00:00
# https://github.com/hashicorp/terraform/blob/83e6703bf77f60660db4465ef50d30c633f800f1/scripts/build.sh
2020-12-14 15:13:47 +00:00
set -eo pipefail
2021-07-15 15:33:35 +00:00
if ! which goreleaser >/dev/null; then
echo "+ Installing goreleaser..."
go install github.com/goreleaser/goreleaser@v0.173.2
fi
2021-07-15 15:33:35 +00:00
# Check configuration
goreleaser check
2021-07-22 08:43:35 +00:00
if [ -z $ENV ]; then
echo "Error: ENV variable must be defined"
exit 1
fi
if [ "$ENV" == "dev" ]; then
echo "+ Building using goreleaser ..."
goreleaser build \
--rm-dist \
--parallelism 2 \
--snapshot \
--single-target
exit 0
fi
GRFLAGS=""
# We sign every releases using PGP
# We may not want to do so in dev environments
if [ -z $SIGNINGKEY ]; then
GRFLAGS+="--skip-sign "
fi
# Only CI system should publish artifacts
if [ "$CI" != "circleci" ]; then
GRFLAGS+="--snapshot "
GRFLAGS+="--skip-announce "
GRFLAGS+="--skip-publish "
fi
echo ${GRFLAGS}
2021-07-15 15:33:35 +00:00
echo "+ Building using goreleaser ..."
2021-07-22 08:43:35 +00:00
goreleaser release \
2021-07-15 15:33:35 +00:00
--rm-dist \
2021-07-22 08:43:35 +00:00
${GRFLAGS}