package main // This should build and upload the binary to mirrors // upload binary to mirrors.wit.com/cloud/control-panel import "log" import "time" import "strings" import "os/user" import "os" import "runtime" import "github.com/davecgh/go-spew/spew" import "git.wit.com/wit/shell" // import "fmt" // import "os/user" // import "io/ioutil" // github.com/bramvdbogaerde/go-scp var BuildMap map[string]*bool var filename string var builddir string func main() { BuildMap = make(map[string]*bool) // shell.Quiet(true) shell.Quiet(false) // shell.Run("git tag --list") // os.Exit(-1) for { shell.Run("git pull --tags") shell.Run("go get -v -u -t") findtags() time.Sleep(time.Second * 5) } } func findtags() { tags := shell.Run("git tag --list") // log.Println(tags) for _, tag := range strings.Split(tags, "\n") { tag = strings.Replace(tag, "v", "", -1) // remove all 'v' chars log.Println("TAG =", tag) if (BuildMap[tag] == nil) { log.Println("\tCHECK IF BUILD WAS ATTEMPTED =", tag) BuildMap[tag] = build(tag) } } // os.Exit(0) } func build(tag string) *bool { url := "https://mirrors.wit.com/cloud/control-panel/linux/clound-control-panel-v" + tag + ".md5sum" md5sum := shell.Chomp(shell.Wget(url)) if (md5sum != "") { log.Println("\tBUILD ALREADY DONE TAG =", tag, "md5sum =", md5sum) var b bool b = true // for {} return &b } // for {} shell.Quiet(false) shell.Run("git checkout v" + tag) gitref := shell.Run("git rev-list -1 HEAD") tagref := shell.Run("cat .git/refs/tags/v" + tag) if (gitref != tagref) { log.Println("\tJESUS.", gitref, "ne", tagref) os.Exit(-1) return nil } shell.Run("rm clound-control-panel") shell.Run("go build") os.Exit(-1) // This version has not been built yet log.Println("\tTRY TO BUILD TAG =", tag) var b bool b = false return &b } func setbuilddir() { user, err := user.Current() spew.Dump(user) if err != nil { os.Exit(-1) } if runtime.GOOS == "linux" { log.Println("loadConfigFile() OS: Linux") filename = "cloud-control-panel" builddir = user.HomeDir + "/go/src/git.wit.com/wit/cloud-control-panel" } else if runtime.GOOS == "windows" { log.Println("loadConfigFile() OS: Windows") builddir = user.HomeDir + "\\go\\src\\git.wit.com\\wit\\cloud-control-panel" filename = "cloud-control-panel.exe" } else { log.Println("loadConfigFile() OS: " + runtime.GOOS) filename = "cloud-control-panel" builddir = user.HomeDir + "/go/src/git.wit.com/wit/cloud-control-panel" } }