Skip to content

Commit 6b9c65b

Browse files
authored
Merge pull request #2491 from buildkite/fix-build-number
Fix build number incorporation
2 parents fe09653 + 35a8daa commit 6b9c65b

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

scripts/build-binary.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@ then
77
exit 1
88
fi
99

10-
export GOOS=${1}
11-
export GOARCH=${2}
10+
export GOOS="$1"
11+
export GOARCH="$2"
1212

13-
BUILD_VERSION=${3}
13+
BUILD_NUMBER="$3"
1414
NAME="buildkite-agent"
1515

16-
if [[ "$GOOS" = "dragonflybsd" ]]; then
16+
if [[ "${GOOS}" = "dragonflybsd" ]]; then
1717
export GOOS="dragonfly"
1818
fi
1919

2020
BUILD_PATH="pkg"
21-
BINARY_FILENAME="$NAME-$GOOS-$GOARCH"
21+
BINARY_FILENAME="${NAME}-${GOOS}-${GOARCH}"
2222

23-
if [[ "$GOARCH" = "armhf" ]]; then
23+
if [[ "${GOARCH}" = "armhf" ]]; then
2424
export GOARCH="arm"
2525
export GOARM="7"
2626
fi
2727

28-
echo -e "Building $NAME with:\n"
28+
echo -e "Building ${NAME} with:\n"
2929

30-
echo "GOOS=$GOOS"
31-
echo "GOARCH=$GOARCH"
32-
if [[ -n "$GOARM" ]]; then
33-
echo "GOARM=$GOARM"
30+
echo "GOOS=${GOOS}"
31+
echo "GOARCH=${GOARCH}"
32+
if [[ -n "${GOARM}" ]]; then
33+
echo "GOARM=${GOARM}"
3434
fi
35-
echo "BUILD_VERSION=$BUILD_VERSION"
35+
echo "BUILD_NUMBER=${BUILD_NUMBER}"
3636
echo ""
3737

3838
# Add .exe for Windows builds
3939
if [[ "$GOOS" == "windows" ]]; then
40-
BINARY_FILENAME="$BINARY_FILENAME.exe"
40+
BINARY_FILENAME="${BINARY_FILENAME}.exe"
4141
fi
4242

4343
# Disable CGO completely
@@ -47,8 +47,8 @@ export CGO_ENABLED=0
4747
"$(dirname $0)"/generate-acknowledgements.sh
4848

4949
mkdir -p $BUILD_PATH
50-
go build -v -ldflags "-X github.com/buildkite/agent/v3/version.buildVersion=$BUILD_VERSION" -o $BUILD_PATH/$BINARY_FILENAME .
50+
go build -v -ldflags "-X github.com/buildkite/agent/v3/version.buildNumber=${BUILD_NUMBER}" -o "${BUILD_PATH}/${BINARY_FILENAME}" .
5151

52-
chmod +x $BUILD_PATH/$BINARY_FILENAME
52+
chmod +x "${BUILD_PATH}/${BINARY_FILENAME}"
5353

54-
echo -e "\nDone: \033[33m$BUILD_PATH/$BINARY_FILENAME\033[0m 💪"
54+
echo -e "\nDone: \033[33m${BUILD_PATH}/${BINARY_FILENAME}\033[0m 💪"

version/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
var (
1515
//go:embed VERSION
1616
baseVersion string
17+
18+
// buildNumber is filled in by scripts/build-binary.sh by passing -ldflags
19+
// "-X github.com/buildkite/agent/v3/version.buildNumber=${BUILDKITE_BUILD_NUMBER}"
1720
buildNumber = "x"
1821
)
1922

0 commit comments

Comments
 (0)