use go-cmd/cmd
This commit is contained in:
parent
f189efd9d7
commit
a68b3400a5
68
doRelease.go
68
doRelease.go
|
@ -6,6 +6,8 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-cmd/cmd"
|
||||||
|
|
||||||
"go.wit.com/lib/gui/repolist"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -149,12 +151,12 @@ func doReleaseFindNext() bool {
|
||||||
// to insert the new version
|
// to insert the new version
|
||||||
func doPublishVersion() bool {
|
func doPublishVersion() bool {
|
||||||
gopath := me.current.GoPath()
|
gopath := me.current.GoPath()
|
||||||
cmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()}
|
docmd := []string{"go", "get", "-v", gopath + "@" + me.release.version.String()}
|
||||||
log.Info("SHOULD RUN cmd HERE:", cmd)
|
log.Info("SHOULD RUN cmd HERE:", docmd)
|
||||||
|
|
||||||
// right now, you can't publish this because the go.* files in this project are screwed up
|
// right now, you can't publish this because the go.* files in this project are screwed up
|
||||||
if me.release.guireleaser == nil {
|
if me.release.guireleaser == nil {
|
||||||
log.Info("CAN NOT SELF UPDATE HERE. cmd =", cmd)
|
log.Info("CAN NOT SELF UPDATE HERE. cmd =", docmd)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
homeDir, _ := os.UserHomeDir()
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
@ -163,37 +165,39 @@ func doPublishVersion() bool {
|
||||||
log.Info("go.sum must exist here")
|
log.Info("go.sum must exist here")
|
||||||
me.release.guireleaser.Status.MakeRedomod()
|
me.release.guireleaser.Status.MakeRedomod()
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
var out string
|
|
||||||
if me.current.Status.IsPrivate() {
|
if me.current.Status.IsPrivate() {
|
||||||
// do not self update private repos
|
// do not self update private repos
|
||||||
err = nil
|
log.Info("This is a private repo and can not be self checked")
|
||||||
out = "This is a private repo and can not be self checked"
|
|
||||||
} else {
|
|
||||||
if gopath == "go.wit.com/apps/guireleaser" {
|
|
||||||
log.Info("CAN NOT SELF UPDATE. cmd =", cmd)
|
|
||||||
log.Info("go get must be run from somewhere else other than guireleaser")
|
|
||||||
err, ok, output := shell.RunCmd("", cmd)
|
|
||||||
log.Info("err =", err)
|
|
||||||
log.Info("ok =", ok)
|
|
||||||
log.Info("output =", output)
|
|
||||||
} else {
|
|
||||||
// publish go.mod & go.sum for use with go
|
|
||||||
os.Unsetenv("GO111MODULE")
|
|
||||||
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
|
|
||||||
err, out = me.release.guireleaser.Status.RunCmd(cmd)
|
|
||||||
if gopath == "go.wit.com/apps/guireleaser" {
|
|
||||||
// ignore errors on updating myself
|
|
||||||
log.Info("IGNORE SELF UPDATE ERROR. cmd =", cmd)
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
log.Info("SELF UPDATE OK. out =", out)
|
|
||||||
log.Info("SELF UPDATE WORKED")
|
|
||||||
// me.current.SetGoState("RELEASED")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
|
// try to pull from google
|
||||||
|
var result cmd.Status
|
||||||
|
if gopath == "go.wit.com/apps/guireleaser" {
|
||||||
|
log.Info("CAN NOT SELF UPDATE. cmd =", docmd)
|
||||||
|
log.Info("go get must be run from somewhere else other than guireleaser")
|
||||||
|
result = shell.PathRun("/home/jcarr/go/src/go.wit.com/apps/autotypist", docmd)
|
||||||
|
} else {
|
||||||
|
// publish go.mod & go.sum for use with go
|
||||||
|
os.Unsetenv("GO111MODULE")
|
||||||
|
log.Info("TRYING TO SELF UPDATE HERE. cmd =", docmd)
|
||||||
|
result = me.release.guireleaser.Status.Run(docmd)
|
||||||
|
}
|
||||||
|
if result.Error != nil {
|
||||||
|
log.Info("SELF UPDATE FAILED. error =", result.Error)
|
||||||
|
log.Info("SELF UPDATE FAILED. exit =", result.Exit)
|
||||||
|
log.Info("SELF UPDATE FAILED. out =", result.Stdout)
|
||||||
|
log.Info("SELF UPDATE FAILED")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if result.Exit != 0 {
|
||||||
|
log.Info("SELF UPDATE FAILED. error =", result.Error)
|
||||||
|
log.Info("SELF UPDATE FAILED. exit =", result.Exit)
|
||||||
|
log.Info("SELF UPDATE FAILED. out =", result.Stdout)
|
||||||
|
log.Info("SELF UPDATE FAILED")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Info("SELF UPDATE OK. out =", result.Stdout)
|
||||||
|
log.Info("SELF UPDATE WORKED")
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
if repo.Status.ReadOnly() {
|
if repo.Status.ReadOnly() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
repo.Status.Run([]string{"rm", "-f", "go.mod", "go.sum"})
|
||||||
}
|
}
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
|
@ -191,7 +191,7 @@ func createReleaseBox(box *gui.Node) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Warn("running git reset --hard", repo.Name())
|
log.Warn("running git reset --hard", repo.Name())
|
||||||
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
|
repo.Status.Run([]string{"git", "reset", "--hard"})
|
||||||
}
|
}
|
||||||
me.Enable()
|
me.Enable()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue