Skip to content

Commit bdfe49c

Browse files
committed
Fix build args for multi-arch-build make target
Signed-off-by: Brad Davidson <[email protected]>
1 parent 35a4347 commit bdfe49c

File tree

6 files changed

+15
-22
lines changed

6 files changed

+15
-22
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
env:
1212
ARCH: amd64
13+
TAG: ${{ github.ref_name }}
1314
permissions:
1415
contents: write # Needed to update release with binary assets
1516
packages: write # Needed for GHCR image push
@@ -95,4 +96,4 @@ jobs:
9596
${{ secrets.DOCKER_USERNAME }}/kine:latest
9697
${{ secrets.DOCKER_USERNAME }}/kine:${{ github.ref_name }}
9798
ghcr.io/${{ github.repository_owner }}/kine:latest
98-
ghcr.io/${{ github.repository_owner }}/kine:${{ github.ref_name }}
99+
ghcr.io/${{ github.repository_owner }}/kine:${{ github.ref_name }}

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ RUN --mount=type=cache,id=gomod,target=/go/pkg/mod \
2626

2727
FROM infra AS build
2828
ARG TAG
29-
ARG DRONE_TAG
29+
ARG DIRTY
3030
ARG ARCH=amd64
31-
ENV ARCH=${ARCH}
31+
ENV TAG=${TAG} DIRTY=${DIRTY} ARCH=${ARCH}
3232

3333
COPY ./scripts/build ./scripts/version ./scripts/
3434
COPY ./go.mod ./go.sum ./main.go ./
@@ -57,9 +57,11 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
5757

5858
FROM --platform=$BUILDPLATFORM golang:1.24-alpine3.22 AS multi-arch-build
5959
COPY --from=xx / /
60+
ARG TAG
61+
ARG DIRTY
6062
ARG TARGETOS
6163
ARG TARGETARCH
62-
ENV CGO_ENABLED=1
64+
ENV TAG=${TAG} DIRTY=${DIRTY} CGO_ENABLED=1
6365
RUN apk -U add bash coreutils git vim less curl wget ca-certificates clang lld
6466
RUN xx-apk add musl-dev gcc
6567
# go imports version gopls/v0.15.3

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ build:
2626
.PHONY: multi-arch-build
2727
PLATFORMS = linux/amd64,linux/arm64,linux/arm/v7,linux/riscv64
2828
multi-arch-build:
29-
docker buildx build --platform=$(PLATFORMS) --target=multi-arch-binary --output=type=local,dest=bin .
29+
docker buildx build --build-arg="REPO=$(REPO)" --build-arg="TAG=$(TAG)" --build-arg="DIRTY=$(DIRTY)" --platform=$(PLATFORMS) --target=multi-arch-binary --output=type=local,dest=bin .
3030
mv bin/linux*/kine* bin/
3131
rmdir bin/linux*
3232
mkdir -p dist/artifacts
@@ -37,4 +37,4 @@ package:
3737
ARCH=$(ARCH) ./scripts/package
3838

3939
.PHONY: ci
40-
ci: validate build package
40+
ci: validate build package

scripts/buildx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Builds kine for multiple platforms and os
33
# Intended to be run within a buildx container that provides the --platform flag
44
# Also needed are the tonistiigi/xx build tools
5-
set -e
5+
set -ex
66

77
source $(dirname $0)/version
88

@@ -27,5 +27,5 @@ fi
2727
LINKFLAGS="-X github.com/k3s-io/kine/pkg/version.Version=$VERSION"
2828
LINKFLAGS="-X github.com/k3s-io/kine/pkg/version.GitCommit=$COMMIT $LINKFLAGS"
2929

30-
echo Building Mutliplaform Kine
31-
CGO_CFLAGS="-DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_USE_ALLOCA=1" xx-go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -tags nats -o bin/kine"${OPT_OS}${ARCH}"
30+
echo Building Multiplatform Kine ${VERSION}
31+
CGO_CFLAGS="-DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_USE_ALLOCA=1" xx-go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -tags nats -o bin/kine"${OPT_OS}${ARCH}"

scripts/test-helpers

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,7 @@ pid-cleanup() {
323323
printf '\033[32mAll tests passed.\033[m\n'
324324
else
325325
printf "\033[31m$failCount tests failed.\033[m\n"
326-
if [ "$DRONE_BUILD_EVENT" = 'tag' ]; then
327-
printf "\033[31mIgnoring test failures on tag.\033[m\n"
328-
code=0
329-
else
330-
code=1
331-
fi
326+
code=1
332327
fi
333328
echo
334329
exit $code

scripts/version

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
#!/bin/bash
22

3-
# Without Dapper, DIRTY is determined in the Makefile and passed in as a build arg/env var
4-
if [ -z "$DIRTY" ] && [ -n "$(git status --porcelain --untracked-files=no)" ]; then
5-
DIRTY="-dirty"
6-
fi
7-
83
COMMIT=$(git rev-parse --short HEAD)
9-
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
4+
GIT_TAG=${TAG:-$(git tag -l --contains HEAD | head -n 1)}
105

11-
if [ -z "$DIRTY" ] && [ -n "$GIT_TAG" ]; then
6+
if [ -z "$DIRTY" ] && [ -n "$GIT_TAG" ] && [ -n "$(git status --porcelain --untracked-files=no)" ]; then
127
VERSION=$GIT_TAG
138
else
149
VERSION="${COMMIT}${DIRTY}"

0 commit comments

Comments
 (0)