Build: Add -buildvcs=false flag to go build

This commit is contained in:
Matheus Macabu 2025-08-11 15:29:46 +02:00
parent 4682a288a3
commit ecbe0bdaf6
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View File

@ -203,6 +203,10 @@ func doBuild(binaryName, pkg string, opts BuildOpts) error {
args = append(args, "-race")
}
// We should not publish Grafana as a Go module, disabling vcs changes the version to (devel)
// and works better with SBOM and Vulnerability Scanners.
args = append(args, "-buildvcs=false")
args = append(args, "-o", binary)
args = append(args, pkg)

View File

@ -34,6 +34,9 @@ func GoLDFlags(flags []LDFlag) string {
// GoBuildCommand returns the arguments for go build to be used in 'WithExec'.
func GoBuildCommand(output string, ldflags []LDFlag, tags []string, main string) []string {
args := []string{"go", "build",
// We should not publish Grafana as a Go module, disabling vcs changes the version to (devel)
// and works better with SBOM and Vulnerability Scanners.
"-buildvcs=false",
fmt.Sprintf("-ldflags=\"%s\"", GoLDFlags(ldflags)),
fmt.Sprintf("-o=%s", output),
"-trimpath",