move autobuild out of this repo
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
236541d379
commit
3f5c15a56a
|
@ -1,2 +0,0 @@
|
||||||
all:
|
|
||||||
go install
|
|
|
@ -1,156 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
// This should build and upload the binary to mirrors
|
|
||||||
|
|
||||||
// upload binary to mirrors.wit.com/cloud/control-panel
|
|
||||||
|
|
||||||
import "log"
|
|
||||||
import "fmt"
|
|
||||||
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 "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)
|
|
||||||
|
|
||||||
setbuilddir()
|
|
||||||
|
|
||||||
// shell.Quiet(true)
|
|
||||||
shell.Quiet(false)
|
|
||||||
|
|
||||||
// shell.Run("git tag --list")
|
|
||||||
// os.Exit(-1)
|
|
||||||
|
|
||||||
for {
|
|
||||||
shell.Run("git checkout master")
|
|
||||||
shell.Run("git pull --tags")
|
|
||||||
findtags()
|
|
||||||
time.Sleep(time.Second * 60)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
if (BuildMap[tag] == nil) {
|
|
||||||
log.Println("TAG =", tag, "is nil")
|
|
||||||
log.Println("\tCHECK IF BUILD WAS ATTEMPTED =", tag)
|
|
||||||
BuildMap[tag] = build(tag)
|
|
||||||
} else {
|
|
||||||
if (*BuildMap[tag] == true) {
|
|
||||||
log.Println("TAG =", tag, "is true")
|
|
||||||
} else {
|
|
||||||
log.Println("TAG =", tag, "is false")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func build(tag string) *bool {
|
|
||||||
var b bool
|
|
||||||
url := "https://mirrors.wit.com/cloud/control-panel/linux/" + filename + "-v" + tag + ".md5sum"
|
|
||||||
log.Println("\tTRYING URL", url)
|
|
||||||
|
|
||||||
md5sum := shell.Chomp(shell.Wget(url))
|
|
||||||
if (md5sum != "") {
|
|
||||||
log.Println("\tBUILD ALREADY DONE TAG =", tag, "md5sum =", md5sum)
|
|
||||||
b = true
|
|
||||||
// for {}
|
|
||||||
return &b
|
|
||||||
}
|
|
||||||
// for {}
|
|
||||||
|
|
||||||
shell.Quiet(false)
|
|
||||||
|
|
||||||
shell.Run("go get -v ...")
|
|
||||||
shell.Run("go get -v -u ...")
|
|
||||||
shell.Run("go get -v -u -t")
|
|
||||||
|
|
||||||
shell.Run("git checkout v" + tag)
|
|
||||||
|
|
||||||
gitref := shell.Run("git rev-list -1 HEAD")
|
|
||||||
tagref := shell.Run("git rev-list -1 v" + tag)
|
|
||||||
|
|
||||||
if (gitref != tagref) {
|
|
||||||
log.Println("\tWHAT WENT WRONG?", gitref, "ne", tagref)
|
|
||||||
b = false
|
|
||||||
return &b
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the files that will end up in the binary
|
|
||||||
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
|
||||||
shell.Write("./resources/build.DATE", epoch)
|
|
||||||
shell.Write("./resources/build.REF", gitref)
|
|
||||||
|
|
||||||
// rebuild the binary (always remove the old one
|
|
||||||
shell.Run("rm " + filename)
|
|
||||||
shell.Run("packr build")
|
|
||||||
md5sum = shell.Run("md5sum " + filename)
|
|
||||||
log.Println("\tmd5sum =", md5sum)
|
|
||||||
|
|
||||||
if (md5sum == "") {
|
|
||||||
log.Println("\tBUILD FAILED")
|
|
||||||
b = false
|
|
||||||
return &b
|
|
||||||
}
|
|
||||||
shell.Write("/tmp/autobuild.md5sum", md5sum)
|
|
||||||
upload(tag)
|
|
||||||
|
|
||||||
// This version has been built yet
|
|
||||||
log.Println("\tTHIS VERSION HAS BEEN UPLOADED =", tag)
|
|
||||||
b = true
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// upload the files to mirrors
|
|
||||||
func upload(tag string) {
|
|
||||||
mirrors := "root@mirrors.wit.com:/data/mirrors/cloud/control-panel/linux/"
|
|
||||||
|
|
||||||
// don't update the master VERSION here
|
|
||||||
// shell.Run("scp resources/VERSION " + mirrors)
|
|
||||||
shell.Run("scp cloud-control-panel " + mirrors)
|
|
||||||
shell.Run("scp resources/BUILDDATE " + mirrors + filename + "-v" + tag + ".BUILDDATE")
|
|
||||||
shell.Run("scp cloud-control-panel " + mirrors + filename + "-v" + tag)
|
|
||||||
shell.Run("scp /tmp/autobuild.md5sum " + mirrors + filename + "-v" + tag + ".md5sum")
|
|
||||||
}
|
|
|
@ -5,71 +5,23 @@ package main
|
||||||
// Then, upload the binaries to mirrors.wit.com/cloud/control-panel
|
// Then, upload the binaries to mirrors.wit.com/cloud/control-panel
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "fmt"
|
//import "fmt"
|
||||||
import "time"
|
//import "time"
|
||||||
import "os/user"
|
//import "os/user"
|
||||||
|
|
||||||
import "git.wit.com/wit/shell"
|
import "git.wit.com/wit/shell"
|
||||||
|
import build "git.wit.com/wit/cloud-control-panel-build"
|
||||||
|
|
||||||
var filename string
|
var filename string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
shell.Quiet(false)
|
shell.Quiet(false)
|
||||||
|
|
||||||
md5sum := build()
|
md5sum := build.Build()
|
||||||
log.Println("\tmd5sum =", md5sum)
|
log.Println("\tmd5sum =", md5sum)
|
||||||
|
|
||||||
if (md5sum == "") {
|
if (md5sum == "") {
|
||||||
log.Println("\tBUILD FAILED")
|
log.Println("\tBUILD FAILED")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// upload test
|
|
||||||
sess := shell.SSH("mirrors.wit.com", 22, "jcarr", "")
|
|
||||||
shell.Scp(sess, filename, "/tmp/jcarr-testing")
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
func build() string {
|
|
||||||
user, _ := user.Current()
|
|
||||||
log.Println("user.HomeDir =", user.HomeDir)
|
|
||||||
|
|
||||||
filename = shell.Execname("cloud-control-panel") // returns the right name for each OS
|
|
||||||
|
|
||||||
gitref := shell.Run("git rev-list -1 HEAD")
|
|
||||||
|
|
||||||
// setup the files that will end up in the binary
|
|
||||||
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
|
||||||
shell.Write("./resources/build.DATE", epoch)
|
|
||||||
shell.Write("./resources/build.REF", gitref)
|
|
||||||
|
|
||||||
// make a dirty file if this build is dirty
|
|
||||||
shell.Run("rm ./resources/build.DIRTY")
|
|
||||||
|
|
||||||
version := shell.Run("cat ./resources/VERSION")
|
|
||||||
versionref := shell.Run("git rev-list -1 v" + version)
|
|
||||||
|
|
||||||
if (gitref != versionref) {
|
|
||||||
log.Println("build is DIRTY", gitref, "!=", versionref)
|
|
||||||
shell.Write("./resources/build.DIRTY", versionref)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test if there are pending diffs. If so, also mark this as dirty.
|
|
||||||
diff := shell.Run("git diff HEAD")
|
|
||||||
if (diff != "") {
|
|
||||||
log.Println("build is DIRTY -- pending diffs")
|
|
||||||
shell.Write("./resources/build.DIRTY", "pending diffs")
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild the binary (always remove the old one
|
|
||||||
shell.Run("rm " + filename)
|
|
||||||
shell.Run("packr build")
|
|
||||||
log.Println("build finished")
|
|
||||||
|
|
||||||
md5sum := shell.Md5sum(filename)
|
|
||||||
log.Println("\tmd5sum =", md5sum)
|
|
||||||
shell.Write("/tmp/build.md5sum", md5sum)
|
|
||||||
|
|
||||||
return md5sum
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue