Generate version during compilation

This commit is contained in:
世界 committed 2023-03-09 23:24:05 +08:00
1 parent 325f6c71ff
commit 1c8a9e91b7
10 files changed
+83 -33

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package build_shared
import (
"github.com/sagernet/sing/common"
)
func ReadTag() (string, error) {
currentTag, err := common.Exec("git", "describe", "--tags").ReadOutput()
if err != nil {
return currentTag, err
}
currentTagRev, _ := common.Exec("git", "describe", "--tags", "--abbrev=0").ReadOutput()
if currentTagRev == currentTag {
return currentTag[1:], nil
}
shortCommit, _ := common.Exec("git", "rev-parse", "--short", "HEAD").ReadOutput()
return currentTagRev[1:] + "-" + shortCommit, nil
}