guireleaser/prepareRelease.go

103 lines
2.5 KiB
Go

package main
import (
"go.wit.com/log"
)
func makePrepareRelease() {
me.Disable()
me.release.box.Disable()
defer me.Enable()
if setAllBranchesToMaster() {
// if it succeeds, disable this button
me.setBranchesToMasterB.Disable()
me.release.box.Enable()
PrintReleaseReport("", "")
} else {
log.Info("setAllBranchesToMaster() failed")
}
// reset all the target versions back to the current version
// incase they were saved in the repos.pb file
all := me.forge.Repos.SortByGoPath()
for all.Scan() {
check := all.Next()
// set the target version to the current master version
curver := check.GetMasterVersion()
check.SetTargetVersion(curver)
}
// run go-mod-clean on everything not readonly
all = me.forge.Repos.SortByGoPath()
for all.Scan() {
check := all.Next()
if me.forge.Config.IsReadOnly(check.GoPath) {
// can't release readonly repos
continue
}
if ok, err := check.IsPrimitive(); !ok {
log.Info("something wrong with", check.GoPath, err)
// no go.sum file for these
continue
}
if check.Exists("go.sum") {
// probably already ran
continue
}
if !runGoClean(check) {
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
}
}
all = me.forge.Repos.SortByGoPath()
for all.Scan() {
check := all.Next()
if me.forge.Config.IsReadOnly(check.GoPath) {
// can't release readonly repos
continue
}
// if master != lastTag, always increment
master := check.GetMasterVersion()
lastTag := check.GetLastTag()
if master != lastTag {
// if v1.2.3 change to v.1.2.4
check.IncrementTargetRevision()
continue
}
// if the repo is a go binary, try forcing new go.* files
if check.RepoType() == "binary" {
// check if the package dependancies changed, if so, re-publish
if me.forge.FinalGoDepsCheckOk(check) {
log.Printf("go.sum is perfect! %s\n", check.GetGoPath())
} else {
log.Printf("dependancy checks indicate a new release is needed for %s\n", check.GetGoPath())
// if v1.2.3 change to v.1.2.4
check.IncrementTargetRevision()
}
}
}
if findNext() {
log.Info("prepare release findNext() returned true")
me.release.box.Enable()
} else {
log.Info("prepare release findNext() returned false")
if findNext() {
log.Info("prepare release findNext() returned true")
me.release.box.Enable()
} else {
log.Info("prepare release findNext() returned false")
}
}
}