-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
23 lines (20 loc) · 799 Bytes
/
Copy pathbuild.sh
File metadata and controls
23 lines (20 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# Release build for envaudit.
#
# Usage:
# ./build.sh # build ./envaudit, version from nearest git tag
# VERSION=1.2.3 ./build.sh # override the version explicitly
#
# The version injected via -ldflags defaults to the nearest `v*` tag
# (`git describe`), falling back to the compile-time default in
# cmd/envaudit/main.go when git isn't available or there are no tags.
set -euo pipefail
DEFAULT_VERSION="1.1.0"
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo "$DEFAULT_VERSION")}"
VERSION="${VERSION#v}"
echo "Building envaudit v${VERSION} ..."
CGO_ENABLED=0 go build -trimpath \
-ldflags "-s -w -X 'main.version=${VERSION}'" \
-o envaudit ./cmd/envaudit
echo "Done: ./envaudit (v${VERSION})"
./envaudit version