File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package internal
22
33import (
44 "context"
5+ "crypto/sha256"
6+ "encoding/base64"
57 "fmt"
68 "io"
79 "os"
@@ -177,8 +179,8 @@ func (b Builder) goBuild(ctx context.Context, binaryName string) error {
177179 cmd := exec .CommandContext (ctx , "go" , "build" ,
178180 "-ldflags" ,
179181 fmt .Sprintf (
180- "-s -w -X 'main.version=%s-custom-gcl ' -X 'main.date=%s'" ,
181- sanitizeVersion (b .cfg .Version ), time .Now ().UTC ().String (),
182+ "-s -w -X 'main.version=%s' -X 'main.date=%s'" ,
183+ createVersion (b .cfg .Version ), time .Now ().UTC ().String (),
182184 ),
183185 "-o" , binaryName ,
184186 "./cmd/golangci-lint" ,
@@ -241,6 +243,13 @@ func (b Builder) getBinaryName() string {
241243 return name
242244}
243245
246+ func createVersion (orig string ) string {
247+ h := sha256 .New ()
248+ h .Write ([]byte (time .Now ().UTC ().String ()))
249+
250+ return sanitizeVersion (orig ) + "-custom-gcl-" + base64 .RawURLEncoding .EncodeToString (h .Sum (nil ))
251+ }
252+
244253func sanitizeVersion (v string ) string {
245254 fn := func (c rune ) bool {
246255 return ! unicode .IsLetter (c ) && ! unicode .IsNumber (c ) && c != '.' && c != '/'
You can’t perform that action at this time.
0 commit comments