guireleaser/prepareRelease.go

115 lines
2.9 KiB
Go
Raw Normal View History

package main
import (
"go.wit.com/log"
)
func makePrepareRelease() {
me.Disable()
me.release.box.Disable()
defer me.Enable()
2024-12-02 08:45:13 -06:00
2024-12-02 10:43:48 -06:00
if setAllBranchesToMaster() {
// if it succeeds, disable this button
me.setBranchesToMasterB.Disable()
me.release.box.Enable()
PrintReleaseReport("", "")
} else {
log.Info("setAllBranchesToMaster() failed")
}
2024-12-12 02:05:47 -06:00
// 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()
2024-12-02 08:45:13 -06:00
// set the target version to the current master version
2024-12-12 02:05:47 -06:00
curver := check.GetMasterVersion()
2024-12-02 08:45:13 -06:00
check.SetTargetVersion(curver)
}
// run go-mod-clean on everything not readonly
2024-12-13 02:21:39 -06:00
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
}
2024-12-14 16:29:14 -06:00
// run go-mod-clean on every repo to start
2024-12-13 02:21:39 -06:00
if !runGoClean(check) {
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
2024-12-02 08:45:13 -06:00
}
}
2024-12-12 02:05:47 -06:00
all = me.forge.Repos.SortByGoPath()
for all.Scan() {
check := all.Next()
2024-12-02 08:45:13 -06:00
2024-12-13 02:21:39 -06:00
if me.forge.Config.IsReadOnly(check.GoPath) {
// can't release readonly repos
continue
}
2024-12-12 02:05:47 -06:00
// 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()
2024-12-14 16:29:14 -06:00
if !runGoClean(check) {
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
}
2024-12-12 02:05:47 -06:00
continue
2024-12-02 08:45:13 -06:00
}
2024-12-12 02:05:47 -06:00
// if the repo is a go binary, try forcing new go.* files
2024-12-14 16:29:14 -06:00
if check.RepoType() != "binary" {
// master and lasttag match and it's not a binary. everything is fine
continue
}
// 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())
continue
}
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()
// run go-mod-clean in each repo that needs to be updated
if master == lastTag {
// 'git notes' has something in it. clear it out
check.Run([]string{"git", "notes", "remove"})
}
if !runGoClean(check) {
log.Info("go-mod-clean FAILED. THIS IS BAD.", check.GoPath)
}
}
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")
}
}
}