From 028788f35789ee81e5246fe9be5e4557e76565d5 Mon Sep 17 00:00:00 2001 From: Slawek Koszewski Date: Sat, 2 Aug 2025 13:45:45 +0200 Subject: [PATCH] Updated build.sh to embed version information to the binary using changes to the version.go file. --- README.md | 10 ++++++++++ build.sh | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a14818f..355fb24 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,16 @@ The tool checks that SANs are valid for the selected certificate type(s). Certif See `examples/example-certificates.hcl` for a more advanced provisioning file with templates and variables. +## Building the Tool + +The repository includes a `build.sh` script to build the CLI tool. It updates the version in `version.go` and builds the binary. + +To ignore changes made to `version.go` in Git, you can run: + +```bash +git update-index --assume-unchanged version.go +``` + --- ## Notes diff --git a/build.sh b/build.sh index 945e39f..1b9e971 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,9 @@ else VERSION="dev" fi +# Hardcode the version into main.go +sed -i '' "s/^var Version = .*/var Version = \"$VERSION\"/" version.go + if echo $VERSION | grep -q 'dirty$'; then echo "Building in development mode, output directory is set to 'build'." OUTPUT_DIR=build @@ -19,4 +22,5 @@ else fi # Build the Lab CA binary with version information -go build -ldflags "-X main.Version=$VERSION" -o $OUTPUT_DIR/lab-ca +# go build -ldflags "-X main.Version=$VERSION" -o $OUTPUT_DIR/lab-ca +go build -o $OUTPUT_DIR/lab-ca