Skip to content

Commit

Permalink
Compile the controller with a version set from git describe
Browse files Browse the repository at this point in the history
  • Loading branch information
triarius committed Mar 7, 2023
1 parent 406d19e commit a8cc47a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 5 additions & 4 deletions .buildkite/steps/controller.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -euxo pipefail

set -Eeufo pipefail

apt update && apt install -y --no-install-recommends jq

Expand All @@ -12,8 +13,8 @@ latest=$(curl -L -s https://api.github.com/repos/ko-build/ko/releases/latest | j
curl -sSfL "https://github.com/ko-build/ko/releases/download/${latest}/ko_${latest:1}_${OS^}_${ARCH}.tar.gz" | tar -xzv -C /bin ko

tag=$(git describe)
ko login ghcr.io -u $REGISTRY_USERNAME --password $REGISTRY_PASSWORD
ko login ghcr.io -u "$REGISTRY_USERNAME" --password "$REGISTRY_PASSWORD"
export KO_DOCKER_REPO=ghcr.io/buildkite/agent-stack-k8s/controller
controller_image=$(ko build --bare --tags "$tag" --platform linux/amd64,linux/arm64)
controller_image=$(VERSION="$tag" ko build --bare --tags "$tag" --platform linux/amd64,linux/arm64)

buildkite-agent meta-data set "controller-image" "${controller_image}"
buildkite-agent meta-data set controller-image "${controller_image}"
14 changes: 14 additions & 0 deletions .ko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defaultPlatforms:
- linux/amd64
- linux/arm64
builds:
- id: agent-k8s-stack
dir: .
main: .
env:
- CGO_ENABLED=0
ldflags:
- -s
- -w
- -extldflags "-static"
- -X github.com/buildkite/agent-stack-k8s/v2/internal/version.version={{.Env.VERSION}}
6 changes: 5 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ agent target os=("linux") arch=("amd64 arm64"):
rm packaging/docker/alpine/buildkite-agent-*
controller *FLAGS:
ko build -P {{FLAGS}}
#!/usr/bin/env bash
set -eufo pipefail
export VERSION=$(git describe)
ko build --preserve-import-paths {{FLAGS}}

deploy *FLAGS:
#!/usr/bin/env bash
Expand Down

0 comments on commit a8cc47a

Please sign in to comment.