diff --git a/main.go b/main.go index baa36b4..2dcb2e5 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,24 @@ package main -import "fmt" +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" +) -func main () { - fmt.Println("version is here") +const header = "package main\nconst Value = \"" + +func main() { + cmd := exec.Command("git", "describe", "--tags", "--abbrev=0") + out, err := cmd.Output() + if err != nil { + fmt.Println(err) + os.Exit(0) + } + version := string(out) + version = version[:len(version)-1] + content := header + version + "\"" + + ioutil.WriteFile("version.go", []byte(content), 0644) }