Skip to content

Commit 7970507

Browse files
committed
scripts: Update compile
1 parent dfb408c commit 7970507

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

scripts/compile.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env bash
22

33
set -e
4+
REPO_ROOT=$(git rev-parse --show-toplevel)
45

5-
go build -o ./bin/aoc-cli ./cmd/*
6+
VERSION=$(git describe --tags "$(git rev-list --tags --max-count=1)")"-local"
7+
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
8+
DATE=$(date "+%Y-%m-%d")
9+
GOVERSION=$(go version | awk '{print $3;}')
10+
GO_BUILD_LDFLAGS="-s -w -X 'main.commit=${COMMIT_HASH}' -X 'main.date=${DATE}' -X 'main.version=${VERSION}' -X 'main.goversion=${GOVERSION}'"
11+
12+
APP="aoc-cli"
13+
MODULE="github.com/oleg-balunenko/advent-of-code"
14+
15+
GO_BUILD_PACKAGE="${MODULE}/cmd/aoc-cli/."
16+
17+
BIN_DIR="${REPO_ROOT}/bin"
18+
rm -rf "${BIN_DIR}"
19+
mkdir -p "${BIN_DIR}"
20+
21+
go build -o "${BIN_DIR}"/"${APP}" -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}"

0 commit comments

Comments
 (0)