2023-07-20 09:26:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-08-02 15:00:34 +00:00
|
|
|
PACKAGE="git.badhouseplants.net/allanger/shoebill"
|
2023-07-20 09:26:25 +00:00
|
|
|
VERSION="$(git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//')"
|
|
|
|
COMMIT_HASH="$(git rev-parse --short HEAD)"
|
|
|
|
BUILD_TIMESTAMP=$(date '+%Y-%m-%dT%H:%M:%S')
|
|
|
|
|
|
|
|
# STEP 2: Build the ldflags
|
|
|
|
|
|
|
|
LDFLAGS=(
|
|
|
|
"-X '${PACKAGE}/internal/build.Version=${VERSION}'"
|
|
|
|
"-X '${PACKAGE}/internal/build.CommitHash=${COMMIT_HASH}'"
|
|
|
|
"-X '${PACKAGE}/internal/build.BuildTime=${BUILD_TIMESTAMP}'"
|
|
|
|
)
|
|
|
|
|
|
|
|
# STEP 3: Actual Go build process
|
|
|
|
|
|
|
|
go build -ldflags="${LDFLAGS[*]}"
|