From b081b86fb71fbd8eff29b37ba16a5d07987293db Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Mon, 15 Nov 2021 10:10:39 +0200 Subject: [PATCH 1/2] Build static binaries for linux --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 33cff780..623599ef 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,16 @@ endif ENVIRONMENT ?= "development" LD_FLAGS = -s -w -X github.com/k0sproject/k0sctl/version.Environment=$(ENVIRONMENT) -X github.com/k0sproject/k0sctl/version.GitCommit=$(GIT_COMMIT) -X github.com/k0sproject/k0sctl/version.Version=$(K0SCTL_VERSION) -BUILD_FLAGS = -trimpath -a -tags "netgo static_build" -installsuffix netgo -ldflags "$(LD_FLAGS) -extldflags '-static'" +BUILD_FLAGS = -trimpath -a -tags "netgo,osusergo,static_build" -installsuffix netgo -ldflags "$(LD_FLAGS) -extldflags '-static'" bin/k0sctl-linux-x64: $(GO_SRCS) - GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o bin/k0sctl-linux-x64 main.go + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o bin/k0sctl-linux-x64 main.go bin/k0sctl-linux-arm64: $(GO_SRCS) - GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) -o bin/k0sctl-linux-arm64 main.go + GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o bin/k0sctl-linux-arm64 main.go bin/k0sctl-linux-arm: $(GO_SRCS) - GOOS=linux GOARCH=arm go build $(BUILD_FLAGS) -o bin/k0sctl-linux-arm main.go + GOOS=linux GOARCH=arm CGO_ENABLED=0 go build $(BUILD_FLAGS) -o bin/k0sctl-linux-arm main.go bin/k0sctl-win-x64.exe: $(GO_SRCS) GOOS=windows GOARCH=amd64 go build $(BUILD_FLAGS) -o bin/k0sctl-win-x64.exe main.go From 5c547df934cc9d57240ccbb05a4ebd2a5927fa51 Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Mon, 15 Nov 2021 10:45:20 +0200 Subject: [PATCH 2/2] Upload artifact --- .github/workflows/go.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3a43f772..bc2763e0 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -45,8 +45,14 @@ jobs: k0sctl key: build-${{ github.run_id }} - - name: Build windows - run: make bin/k0sctl-win-x64.exe + - name: Build all + run: make build-all + + - uses: actions/upload-artifact@v2 + with: + name: k0sctl-linux-x64 + path: bin/k0sctl-linux-x64 + retention-days: 2 smoke-basic: strategy: