package main // This should build and upload the binary to mirrors import "log" // import "fmt" import "os" import "os/user" import "time" import "runtime" // import "io/ioutil" // import "strings" // github.com/bramvdbogaerde/go-scp import "github.com/davecgh/go-spew/spew" import "git.wit.com/wit/shell" var filename string var builddir string var homedir string func main() { // set build -ldflags for windows and macos // " // -X main.GITCOMMIT=${GITCOMMIT} // -X main.GOVERSION='${GOVERSION}' // -X main.BUILDTIME='${BUILDTIME}' // -X main.VERSION=${VERSION} // " // upload binary to mirrors.wit.com/cloud/control-panel for { build() os.Exit(0) time.Sleep(time.Second * 5) } } func build() { tags := shell.Run("git tag --list") log.Println(tags) os.Exit(0) // shell.SetDelayInMsec(50) shell.Run("go get -v .") // -ldflags -H=windowsgui shell.Run("rm " + filename) if runtime.GOOS == "windows" { shell.Run("go build -ldflags -H=windowsgui") } else { shell.Run("go build") } output := shell.Run("ls -l") shell.Run("cat VERSION") log.Println("output =", output) } func ping() { shell.SetDelayInMsec(2000) shell.Run("ping -c 6 localhost") } // func setupUser() string, string, string { func setupUser() { // look up the user information user, err := user.Current() if err != nil { os.Exit(-1) } spew.Dump(user) // TODO: confirm this is correct for MacOS and Windows 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) builddir = user.HomeDir + "/go/src/git.wit.com/wit/cloud-control-panel" filename = "cloud-control-panel" } homedir = user.HomeDir }