Skip to content

Commit 8f8a0ab

Browse files
committed
add a build script and use it to define a commit version with git rev-parse
1 parent b640d1b commit 8f8a0ab

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go build -buildmode=pie -ldflags "-s -w -X 'main.COMMIT=`git rev-parse --short HEAD`'" -gcflags "all=-trimpath=$GOPATH"

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"ret/util"
1212
)
1313

14-
const (
15-
VERSION = "0.1.24"
14+
var (
15+
COMMIT = ""
1616
)
1717

1818
func main() {
@@ -52,7 +52,7 @@ func main() {
5252
"🔪 " + theme.StartUnderline + "chef" + theme.StopUnderline + "\n" +
5353
theme.StopUnderline + theme.ColorReset)
5454

55-
fmt.Printf(theme.ColorGray+"https://github.com/rerrorctf/ret "+theme.ColorPurple+"%s\n"+theme.ColorBlue, VERSION)
55+
fmt.Printf(theme.ColorReset+"https://github.com/rerrorctf/ret "+theme.ColorPurple+"%s\n"+theme.ColorBlue, COMMIT)
5656
}
5757

5858
flag.Parse()

0 commit comments

Comments
 (0)