From 4e4d6a3213a45231a9261fa4876b74e9035c4505 Mon Sep 17 00:00:00 2001 From: Tamas Levai Date: Sat, 11 May 2024 12:21:51 +0200 Subject: [PATCH] chore(CI/CD): Strip debug info from built binaries --- .github/workflows/publish--add-binaries.yml | 2 +- Dockerfile | 2 +- Makefile | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish--add-binaries.yml b/.github/workflows/publish--add-binaries.yml index 39882a2..14c71c0 100644 --- a/.github/workflows/publish--add-binaries.yml +++ b/.github/workflows/publish--add-binaries.yml @@ -47,7 +47,7 @@ jobs: - name: Build binaries run: | export CGO_ENABLED=0 GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} - make build + make build-bin mv bin/turncat turncat-v${{ steps.vars.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.file_end }} mv bin/stunnerctl stunnerctl-v${{ steps.vars.outputs.tag }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.file_end }} diff --git a/Dockerfile b/Dockerfile index 56c8c2f..c2b2d18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN apkArch="$(apk --print-arch)"; \ esac; \ export CGO_ENABLED=0; \ export GOOS=linux; \ - make build + make build-bin ########### # STUNNERD diff --git a/Makefile b/Makefile index 8e7973f..7b2389f 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ BUILD_DIR ?= bin/ VERSION ?= $(shell (git describe --tags --abbrev=8 --always --long) | tr "/" "-") COMMIT_HASH ?= $(shell git rev-parse --short HEAD 2>/dev/null) BUILD_DATE ?= $(shell date +%FT%T%z) +LDFLAGS += -s -w LDFLAGS += -X main.version=${VERSION} -X main.commitHash=${COMMIT_HASH} -X main.buildDate=${BUILD_DATE} GOARGS = -trimpath @@ -35,7 +36,10 @@ test: generate fmt vet ##@ Build .PHONY: build -build: generate fmt vet +build: generate fmt vet build-bin + +.PHONY: build-bin +build-bin: go build ${GOARGS} -ldflags "${LDFLAGS}" -o ${BUILD_DIR}/stunnerd cmd/stunnerd/main.go go build ${GOARGS} -ldflags "${LDFLAGS}" -o ${BUILD_DIR}/turncat cmd/turncat/main.go go build ${GOARGS} -o ${BUILD_DIR}/stunnerctl cmd/stunnerctl/main.go