8000 Allow to build single binary in release mode by eliecharra Β· Pull Request #895 Β· snyk/driftctl Β· GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow to build single binary in release mode #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ARG ARCH="amd64"

WORKDIR /go/src/app
COPY go.mod go.sum Makefile ./
RUN make deps
RUN go mod download
COPY . .
RUN make release
RUN SINGLE_TARGET=true make release

FROM alpine:3.13

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ all: fmt lint test build go.mod

.PHONY: build
build:
ENV=dev ./scripts/build.sh
SINGLE_TARGET=true ./scripts/build.sh

.PHONY: release
release:
Expand Down
47 changes: 23 additions & 24 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,36 @@ if ! which goreleaser >/dev/null; then
go install github.com/goreleaser/goreleaser@v0.173.2
fi

if [ -z $ENV ]; then
echo "Error: ENV variable must be defined"
exit 1
fi
export ENV="${ENV:-dev}"
SINGLE_TARGET="${SINGLE_TARGET:-false}"

# Check configuration
goreleaser check

if [ "$ENV" == "dev" ]; then
echo "+ Building using goreleaser ..."
goreleaser build \
--rm-dist \
--parallelism 2 \
--snapshot \
--single-target
exit 0
fi
FLAGS=""
FLAGS+="--rm-dist "
FLAGS+="--snapshot "
FLAGS+="--parallelism 2 "

CMD="release"

GRFLAGS=""
if [ "$SINGLE_TARGET" == "true" ]; then
CMD="build"
FLAGS+="--single-target "
fi

# Only CI system should publish artifacts
# We may not want to sign artifacts in dev environments
if [ "$CI" != true ]; then
GRFLAGS+="--snapshot "
GRFLAGS+="--skip-announce "
GRFLAGS+="--skip-publish "
GRFLAGS+="--skip-sign "
if [ "$CI" != true ] && [ "$CMD" == "release" ]; then
FLAGS+="--skip-announce "
FLAGS+="--skip-publish "
FLAGS+="--skip-sign "
fi

echo "+ Building using goreleaser ..."
goreleaser release \
--rm-dist \
--parallelism 2 \
${GRFLAGS}
CMD="goreleaser ${CMD} ${FLAGS}"

echo "+ Building using goreleaser"
echo "+ ENV=${ENV}"
echo "+ CMD=${CMD}"

$CMD
0