2018-03-08 00:42:11 +01:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
)
|
|
|
|
|
|
|
|
var versionTmpl = `package util
|
|
|
|
|
2018-03-27 22:12:47 +02:00
|
|
|
//Version is the Semaphore build version as a string
|
2018-03-08 00:42:11 +01:00
|
|
|
var Version = "{{ .VERSION }}"
|
|
|
|
`
|
|
|
|
|
|
|
|
func main(){
|
|
|
|
|
|
|
|
if len(os.Args) <= 1 {
|
|
|
|
log.Fatalln("Must pass in version number")
|
|
|
|
}
|
|
|
|
|
|
|
|
data := make(map[string]string)
|
|
|
|
data["VERSION"] = os.Args[1]
|
|
|
|
|
|
|
|
tmpl := template.New("version")
|
|
|
|
var err error
|
|
|
|
if tmpl, err = tmpl.Parse(versionTmpl); err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := os.Create("util/version.go")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
defer func(r *os.File) {
|
|
|
|
err = r.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
}(f)
|
|
|
|
|
2018-03-27 22:12:47 +02:00
|
|
|
err = tmpl.Execute(f, data)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
2018-03-08 00:42:11 +01:00
|
|
|
}
|