From 9d6305944146f315930cb977bc2bf58df90f3fe2 Mon Sep 17 00:00:00 2001 From: Nikos Date: Fri, 20 Oct 2023 16:56:09 +0300 Subject: [PATCH] fix: add necessary ldflags --- rockcraft.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 09f5668..e3e6911 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -48,7 +48,17 @@ parts: source-type: git source-tag: v1.3.3 override-build: | - go build -o ${CRAFT_PART_INSTALL}/bin/openfga ./cmd/openfga + build_ver="${src_config_path}/config.Version" + build_hash="${src_config_path}/config.Commit" + build_date="${src_config_path}/config.Date" + go_linker_flags="-s \ + -w \ + -X ${build_ver}=$(git -C "${CRAFT_PART_SRC}" describe --tags) \ + -X ${build_hash}=$(git -C "${CRAFT_PART_SRC}" rev-parse HEAD) \ + -X ${build_date}=$(date -u +%Y-%m-%dT%H:%M:%SZ)" + + go mod download + go build -ldflags="${go_linker_flags}" -o ${CRAFT_PART_INSTALL}/bin/openfga ./cmd/openfga grpc_health_probe: plugin: go