Skip to content

Commit 4ec78f4

Browse files
fix: inject version and commit via ldflags in CI builds (#621)
The release and build workflows called go build without -ldflags, so the binary always had Version=0.0.0 and GitCommit=HEAD. - release.yml: inject both Version (from tag) and GitCommit - build.yml: inject GitCommit (no version tag on main builds) Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
1 parent 03f5914 commit 4ec78f4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
output_name+=".exe"
4040
fi
4141
echo "Building $output_name"
42-
GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" ./main.go
42+
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X github.com/Mirantis/launchpad/version.GitCommit=$GITHUB_SHA" -o "$output_name" ./main.go
4343
done
4444
4545
- name: Upload artifacts

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
output_name+=".exe"
4141
fi
4242
echo "Building $output_name"
43-
GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" ./main.go
43+
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X github.com/Mirantis/launchpad/version.Version=${VERSION#v} -X github.com/Mirantis/launchpad/version.GitCommit=$GITHUB_SHA" -o "$output_name" ./main.go
4444
done
4545
- name: Generate checksums
4646
run: |

0 commit comments

Comments
 (0)