Skip to content

Commit

Permalink
Merge pull request #2491 from buildkite/fix-build-number
Browse files Browse the repository at this point in the history
Fix build number incorporation
  • Loading branch information
DrJosh9000 authored Nov 9, 2023
2 parents fe09653 + 35a8daa commit 6b9c65b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
32 changes: 16 additions & 16 deletions scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ then
exit 1
fi

export GOOS=${1}
export GOARCH=${2}
export GOOS="$1"
export GOARCH="$2"

BUILD_VERSION=${3}
BUILD_NUMBER="$3"
NAME="buildkite-agent"

if [[ "$GOOS" = "dragonflybsd" ]]; then
if [[ "${GOOS}" = "dragonflybsd" ]]; then
export GOOS="dragonfly"
fi

BUILD_PATH="pkg"
BINARY_FILENAME="$NAME-$GOOS-$GOARCH"
BINARY_FILENAME="${NAME}-${GOOS}-${GOARCH}"

if [[ "$GOARCH" = "armhf" ]]; then
if [[ "${GOARCH}" = "armhf" ]]; then
export GOARCH="arm"
export GOARM="7"
fi

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

echo "GOOS=$GOOS"
echo "GOARCH=$GOARCH"
if [[ -n "$GOARM" ]]; then
echo "GOARM=$GOARM"
echo "GOOS=${GOOS}"
echo "GOARCH=${GOARCH}"
if [[ -n "${GOARM}" ]]; then
echo "GOARM=${GOARM}"
fi
echo "BUILD_VERSION=$BUILD_VERSION"
echo "BUILD_NUMBER=${BUILD_NUMBER}"
echo ""

# Add .exe for Windows builds
if [[ "$GOOS" == "windows" ]]; then
BINARY_FILENAME="$BINARY_FILENAME.exe"
BINARY_FILENAME="${BINARY_FILENAME}.exe"
fi

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

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

chmod +x $BUILD_PATH/$BINARY_FILENAME
chmod +x "${BUILD_PATH}/${BINARY_FILENAME}"

echo -e "\nDone: \033[33m$BUILD_PATH/$BINARY_FILENAME\033[0m 💪"
echo -e "\nDone: \033[33m${BUILD_PATH}/${BINARY_FILENAME}\033[0m 💪"
3 changes: 3 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
var (
//go:embed VERSION
baseVersion string

// buildNumber is filled in by scripts/build-binary.sh by passing -ldflags
// "-X github.com/buildkite/agent/v3/version.buildNumber=${BUILDKITE_BUILD_NUMBER}"
buildNumber = "x"
)

Expand Down

0 comments on commit 6b9c65b

Please sign in to comment.