From ae9df69708a449ac75897e6d821a0a514a8054fe 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 09f5668..41b3557 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -48,7 +48,18 @@ parts: source-type: git source-tag: v1.3.3 override-build: | - go build -o ${CRAFT_PART_INSTALL}/bin/openfga ./cmd/openfga + src_config_path="github.com/openfga/openfga/internal" + 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