start looping releases

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-09 11:50:16 -06:00
parent 7aca2fcb69
commit 17e1a099c4
6 changed files with 164 additions and 122 deletions

View File

@ -1,4 +1,3 @@
// This is a simple example
package main
import (

131
doRelease.go Normal file
View File

@ -0,0 +1,131 @@
// This is a simple example
package main
import (
"os"
"strings"
"go.wit.com/log"
)
func doRelease() bool {
if release.releaseVersionB.String() != "release version "+release.version.String() {
log.Warn("something went wrong with the release.version:", release.version.String())
return false
}
if strings.HasPrefix(release.version.String(), "v") {
log.Warn("everything is ok. version starts with v.", release.version.String())
} else {
log.Warn("version does not start with v.", release.version.String())
return false
}
switch release.status.String() {
case "PRIMATIVE":
log.Warn("can do PRIMATIVE", release.version.String())
case "GOOD":
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
case "manually chosen":
log.Warn("attempting manual release", release.version.String())
case "NOT READY":
log.Warn("attempting to release. TODO: recheck go.sum here", release.version.String())
log.Warn("Sleep 10")
log.Sleep(10)
case "UNRELEASED":
log.Warn("attempting to release. TODO: dig deep on go.sum here", release.version.String())
log.Warn("Sleep 10")
log.Sleep(10)
default:
log.Warn("what is this?", release.version.String(), release.status.String())
return false
}
if release.current.status.ReadOnly() {
log.Info("sorry, it's read-only")
return true
}
if release.current.status.CheckDirty() {
log.Info("sorry, it's still dirty")
return false
}
curName := release.current.status.GetCurrentBranchName()
mName := release.current.status.GetMasterBranchName()
if curName != mName {
log.Info("\trepo is not working from main branch", curName, "!=", mName)
return false
}
log.Info("\ttag and push", curName, release.version.String(), me.releaseReasonS)
var all [][]string
all = append(all, []string{"git", "add", "-f", "go.mod"})
if release.current.status.CheckPrimativeGoMod() {
// don't add go.sum here. TODO: check for go.sum file and fail
} else {
all = append(all, []string{"git", "add", "-f", "go.sum"})
}
all = append(all, []string{"git", "commit", "-m", me.releaseReasonS})
all = append(all, []string{"git", "push"})
all = append(all, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
all = append(all, []string{"git", "push", "origin", release.version.String()})
if doAll(release.current, all) {
log.Info("EVERYTHING OK")
gopath := release.current.String()
cmd := []string{"go", "get", "-v", gopath + "@" + release.version.String()}
log.Info("SHOULD RUN cmd HERE:", cmd)
if release.guireleaser == nil {
log.Info("CAN NOT SELF UPDATE HERE. cmd =", cmd)
return false
} else {
os.Unsetenv("GO111MODULE")
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
err, out := 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")
release.current.setGoSumStatus("RELEASED")
release.current.status.UpdateCurrent()
// repo.newScan()
cbname := release.current.status.GetCurrentBranchName()
cbversion := release.current.status.GetCurrentBranchVersion()
lasttag := release.current.status.GetLastTagVersion()
release.current.lastTag.SetLabel(lasttag)
release.current.vLabel.SetLabel(cbname + " " + cbversion)
// scan for new repo
if findNextDirty("") {
log.Info("findNextDirty() found something")
} else {
log.Info("findNextDirty() could not find anything")
return false
}
release.current.status.CheckSafeGoSumRemake()
release.current.status.MakeRedomod()
if ok, _ := release.current.status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// release.current.setGoSumStatus("CLEAN")
release.status.SetValue("GOOD")
release.notes.SetValue("CheckGoSum() does not seem to lie")
return true
} else {
return false
}
} else {
log.Info("SELF UPDATE FAILED err =", err)
log.Info("SELF UPDATE FAILED out =", out)
return false
}
}
}
log.Info("doAll() failed")
return false
}

View File

@ -1,4 +1,3 @@
// This is a simple example
package main
import (
@ -9,7 +8,6 @@ import (
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
// "go.wit.com/gui/gadgets"
)
func showHideRepos() {

15
main.go
View File

@ -1,4 +1,3 @@
// This is a simple example
package main
import (
@ -7,11 +6,15 @@ import (
"strings"
"time"
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/log"
)
// TODO: autocompute these in the gui
var releaseReasonS string = "dropdown fixes"
var releaseVersion string = "0.20.2"
var widgetVersion string = "1.1.17"
//go:embed resources/*
var resToolkit embed.FS
@ -30,16 +33,16 @@ func main() {
repoworld()
me.releaseReasonS = "checkbox fixes"
me.releaseReasonS = releaseReasonS
for _, repo := range me.allrepos {
repo.status.UpdateCurrent()
repo.newScan()
if repo.String() == "go.wit.com/widget" {
repo.targetVersion.SetText("v" + "1.1.16")
repo.targetVersion.SetText("v" + widgetVersion)
} else {
repo.targetVersion.SetText("v" + "0.20.1")
repo.targetVersion.SetText("v" + releaseVersion)
}
if strings.HasPrefix(repo.String(), "go.wit.com/dev/") {
lasttag := repo.status.GetLastTagVersion()

View File

@ -1,12 +1,10 @@
// This is a simple example
package main
import (
"os"
"go.wit.com/log"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func doesExist(path string) bool {

View File

@ -4,7 +4,6 @@ package main
import (
"os"
"path/filepath"
"strings"
"go.wit.com/gui"
"go.wit.com/log"
@ -86,119 +85,14 @@ func createReleaseBox(box *gui.Node) {
return
}
})
release.releaseVersionB = release.grid.NewButton("release version", func() {
buttonDisable()
if release.releaseVersionB.String() != "release version "+release.version.String() {
log.Warn("something went wrong with the release.version:", release.version.String())
return
}
if strings.HasPrefix(release.version.String(), "v") {
log.Warn("everything is ok. version starts with v.", release.version.String())
} else {
log.Warn("version does not start with v.", release.version.String())
return
}
switch release.status.String() {
case "PRIMATIVE":
log.Warn("can do PRIMATIVE", release.version.String())
case "GOOD":
log.Warn("GOOD. lots of go.sum checks passed", release.version.String())
case "manually chosen":
log.Warn("attempting manual release", release.version.String())
case "NOT READY":
log.Warn("attempting to release. TODO: recheck go.sum here", release.version.String())
log.Warn("Sleep 10")
log.Sleep(10)
case "UNRELEASED":
log.Warn("attempting to release. TODO: dig deep on go.sum here", release.version.String())
log.Warn("Sleep 10")
log.Sleep(10)
default:
log.Warn("what is this?", release.version.String(), release.status.String())
return
}
if release.current.status.ReadOnly() {
log.Info("sorry, it's read-only")
return
}
if release.current.status.CheckDirty() {
log.Info("sorry, it's still dirty")
return
}
curName := release.current.status.GetCurrentBranchName()
mName := release.current.status.GetMasterBranchName()
if curName != mName {
log.Info("\trepo is not working from main branch", curName, "!=", mName)
return
}
log.Info("\ttag and push", curName, release.version.String(), me.releaseReasonS)
var all [][]string
all = append(all, []string{"git", "add", "-f", "go.mod"})
if release.current.status.CheckPrimativeGoMod() {
// don't add go.sum here. TODO: check for go.sum file and fail
} else {
all = append(all, []string{"git", "add", "-f", "go.sum"})
}
all = append(all, []string{"git", "commit", "-m", me.releaseReasonS})
all = append(all, []string{"git", "push"})
all = append(all, []string{"git", "tag", "-m", me.releaseReasonS, release.version.String()})
all = append(all, []string{"git", "push", "origin", release.version.String()})
if doAll(release.current, all) {
log.Info("EVERYTHING OK")
gopath := release.current.String()
cmd := []string{"go", "get", "-v", gopath + "@" + release.version.String()}
log.Info("SHOULD RUN cmd HERE:", cmd)
if release.guireleaser == nil {
log.Info("CAN NOT SELF UPDATE HERE. cmd =", cmd)
return
} else {
os.Unsetenv("GO111MODULE")
log.Info("TRYING TO SELF UPDATE HERE. cmd =", cmd)
err, out := 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")
release.current.setGoSumStatus("RELEASED")
release.current.status.UpdateCurrent()
// repo.newScan()
cbname := release.current.status.GetCurrentBranchName()
cbversion := release.current.status.GetCurrentBranchVersion()
lasttag := release.current.status.GetLastTagVersion()
release.current.lastTag.SetLabel(lasttag)
release.current.vLabel.SetLabel(cbname + " " + cbversion)
// scan for new repo
findNextDirty("")
release.current.status.CheckSafeGoSumRemake()
release.current.status.MakeRedomod()
if ok, _ := release.current.status.CheckGoSum(); ok {
log.Info("repo has go.sum requirements that are clean")
// release.current.setGoSumStatus("CLEAN")
release.status.SetValue("GOOD")
release.notes.SetValue("CheckGoSum() does not seem to lie")
}
} else {
log.Info("SELF UPDATE FAILED err =", err)
log.Info("SELF UPDATE FAILED out =", out)
return
}
}
if doRelease() {
buttonEnable()
log.Info("doRelease() worked")
} else {
log.Info("SOMETHING FAILED")
log.Info("doRelease() failed")
}
})
@ -341,6 +235,24 @@ func createReleaseBox(box *gui.Node) {
}
buttonEnable()
})
release.grid.NewButton("release(5)", func() {
buttonDisable()
for n := 0; n <= 5; n++ {
if doRelease() {
log.Info("doRelease() worked")
} else {
if release.status.String() == "ALL DONE?" {
log.Info("maybe ALL DONE?")
buttonEnable()
return
}
log.Info("doRelease() failed")
return
}
}
buttonEnable()
})
}
func goodCheckGoSum() bool {
@ -571,6 +483,7 @@ func findNextDirty(onlyKind string) bool {
}
}
log.Info("tried to findNextDirty() but not sure what to do next")
release.status.SetValue("ALL DONE?")
return false
}