start the automation of version re-release

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-02 03:34:14 -06:00
parent f35f420b8a
commit b07ef2498f
2 changed files with 92 additions and 59 deletions

View File

@ -8,12 +8,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
func createUnreleaseBox(box *gui.Node) { func findUnreleased() bool {
group := release.box.NewGroup("undo and redo things")
group.NewButton("find the unreleased", func() {
me.Disable()
defer me.Enable()
for _, repo := range me.allrepos { for _, repo := range me.allrepos {
if whitelist(repo.String()) { if whitelist(repo.String()) {
log.Info("skipping whitelist", repo.String()) log.Info("skipping whitelist", repo.String())
@ -24,35 +19,83 @@ func createUnreleaseBox(box *gui.Node) {
if repo.lookToUnwind() { if repo.lookToUnwind() {
log.Info("found something to unwind:", repo.String()) log.Info("found something to unwind:", repo.String())
if setCurrentRepo(repo, "rewind this", "very sure") { if setCurrentRepo(repo, "rewind this", "very sure") {
return true
} }
return return false
} }
} }
return false
}
func createUnreleaseBox(box *gui.Node) {
group := release.box.NewGroup("undo and redo things")
group.NewButton("find the unreleased", func() {
me.Disable()
defer me.Enable()
findUnreleased()
}) })
release.unreleaseB = group.NewButton("re-release", func() { release.unreleaseB = group.NewButton("re-release", func() {
// var count int = 0
me.Disable() me.Disable()
if rerelease() {
log.Info("good to re-release another one")
} else {
log.Info("loop(3) failed")
return
}
me.Enable()
})
group.NewButton("loop(5)", func() {
me.Disable()
for n := 0; n <= 5; n++ {
if rerelease() {
log.Info("good to re-release another one")
} else {
log.Info("loop(3) failed")
return
}
}
log.Info("loop(5) worked")
me.Enable()
})
}
func doAll(r *repo, all [][]string) bool {
for _, cmd := range all {
log.Info("doAll() RUNNING: cmd =", cmd)
err, out := r.status.RunCmd(cmd)
log.Info("doAll() err =", err)
log.Info("doAll() out =", out)
if err != nil {
return false
}
}
return true
}
func rerelease() bool {
if release.unreleaseB.String() != "un-release version "+release.version.String() { if release.unreleaseB.String() != "un-release version "+release.version.String() {
log.Warn("something went wrong with the release.version:", release.version.String()) log.Warn("something went wrong with the release.version:", release.version.String())
return return false
} }
if strings.HasPrefix(release.version.String(), "v") { if strings.HasPrefix(release.version.String(), "v") {
log.Warn("everything is ok. version starts with v.", release.version.String()) log.Warn("everything is ok. version starts with v.", release.version.String())
} else { } else {
log.Warn("version does not start with v.", release.version.String()) log.Warn("version does not start with v.", release.version.String())
return return false
} }
if release.current.status.CheckDirty() { if release.current.status.CheckDirty() {
log.Info("sorry, it's still dirty") log.Info("sorry, it's still dirty")
return return false
} }
curName := release.current.status.GetCurrentBranchName() curName := release.current.status.GetCurrentBranchName()
mName := release.current.status.GetMasterBranchName() mName := release.current.status.GetMasterBranchName()
if curName != mName { if curName != mName {
log.Info("\trepo is not working from main branch", curName, "!=", mName) log.Info("\trepo is not working from main branch", curName, "!=", mName)
return return false
} }
log.Info("\treset to devel", curName, release.version.String(), release.reasonS) log.Info("\treset to devel", curName, release.version.String(), release.reasonS)
@ -70,23 +113,13 @@ func createUnreleaseBox(box *gui.Node) {
all = append(all, []string{"git", "push", "origin", release.version.String()}) all = append(all, []string{"git", "push", "origin", release.version.String()})
if doAll(release.current, all) { if doAll(release.current, all) {
log.Info("EVERYTHING OK") log.Info("EVERYTHING OK. RERELEASED", release.current.String())
me.Enable() if findUnreleased() {
log.Info("GOOD TO RUN ANOTHER DAY ON:", release.current.String())
}
} else { } else {
log.Info("SOMETHING FAILED") log.Info("SOMETHING FAILED")
}
})
}
func doAll(r *repo, all [][]string) bool {
for _, cmd := range all {
log.Info("doAll() RUNNING: cmd =", cmd)
err, out := r.status.RunCmd(cmd)
log.Info("doAll() err =", err)
log.Info("doAll() out =", out)
if err != nil {
return false return false
} }
}
return true return true
} }