add build versioning

This commit is contained in:
AJ ONeal 2020-05-25 10:52:37 -06:00
parent 2813ffcbd3
commit e55620ccba
1 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,5 @@
//go:generate go run -mod=vendor git.rootprojects.org/root/go-gitver
package main
import (
@ -19,6 +21,15 @@ import (
_ "github.com/joho/godotenv/autoload"
)
var (
// GitRev refers to the abbreviated commit hash
GitRev = "0000000"
// GitVersion refers to the most recent tag, plus any commits made since then
GitVersion = "v0.0.0-pre0+0000000"
// GitTimestamp refers to the timestamp of the most recent commit
GitTimestamp = "0000-00-00T00:00:00+0000"
)
type Forward struct {
scheme string
pattern string
@ -45,6 +56,13 @@ func main() {
locals := flag.String("locals", "", "a list of <from-domain>:<to-port>")
flag.Parse()
if len(os.Args) >= 2 {
if "version" == os.Args[1] {
fmt.Printf("telebit %s %s %s", GitVersion, GitRev, GitTimestamp)
os.Exit(0)
}
}
if "" != *acmeDirectory {
if *acmeStaging {
fmt.Fprintf(os.Stderr, "pick either acme-directory or acme-staging\n")