2024-12-02 07:00:28 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-12-17 23:59:08 -06:00
|
|
|
"go.wit.com/lib/protobuf/forgepb"
|
2024-12-16 00:19:03 -06:00
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
2024-12-02 07:00:28 -06:00
|
|
|
"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()
|
2024-12-17 21:58:14 -06:00
|
|
|
me.forge.PrintReleaseReport(me.found)
|
2024-12-02 10:43:48 -06:00
|
|
|
} else {
|
|
|
|
log.Info("setAllBranchesToMaster() failed")
|
|
|
|
}
|
|
|
|
|
2024-12-17 23:59:08 -06:00
|
|
|
// run this each time something gets published successfully
|
|
|
|
rePrepareRelease()
|
|
|
|
|
|
|
|
if findNext() {
|
|
|
|
log.Info("prepare release findNext() returned true")
|
|
|
|
}
|
|
|
|
|
|
|
|
me.release.box.Enable()
|
|
|
|
}
|
|
|
|
|
|
|
|
func forceReleaseVersion(repo *gitpb.Repo) {
|
|
|
|
if argv.Minor {
|
|
|
|
// if v1.2.3 change to v.1.3.0
|
|
|
|
repo.IncrementTargetMinor()
|
|
|
|
} else {
|
|
|
|
// if v1.2.3 change to v.1.2.4
|
|
|
|
repo.IncrementTargetRevision()
|
|
|
|
}
|
|
|
|
// empty git notes
|
|
|
|
repo.Run([]string{"git", "notes", "remove"})
|
|
|
|
|
2024-12-18 20:08:48 -06:00
|
|
|
if !runGoClean(repo, "--restore") {
|
2024-12-17 23:59:08 -06:00
|
|
|
log.Info("go-mod-clean probably failed here. that's ok", repo.GetGoPath())
|
2024-12-18 20:24:28 -06:00
|
|
|
// os.Exit(-1)
|
2024-12-17 23:59:08 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func rePrepareRelease() {
|
|
|
|
// reload the config
|
|
|
|
me.forge = forgepb.Init()
|
|
|
|
me.found = new(gitpb.Repos)
|
|
|
|
|
2024-12-17 15:36:54 -06:00
|
|
|
// blank all the target versions incase they were saved in the config .pb file
|
2024-12-17 07:03:17 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-12 02:05:47 -06:00
|
|
|
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-17 21:58:14 -06:00
|
|
|
lastTag := check.GetLastTag()
|
|
|
|
check.SetTargetVersion(lastTag)
|
2024-12-18 20:24:28 -06:00
|
|
|
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
|
|
|
// can't release readonly repos
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if me.forge.Config.IsPrivate(check.GetGoPath()) {
|
|
|
|
// can't release readonly repos
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !runGoClean(check, "--restore") {
|
|
|
|
log.Info("go-mod-clean probably failed here. that's ok", check.GetGoPath())
|
|
|
|
// os.Exit(-1)
|
|
|
|
}
|
2024-12-02 08:45:13 -06:00
|
|
|
}
|
|
|
|
|
2024-12-17 07:03:17 -06:00
|
|
|
all = me.forge.Repos.SortByFullPath()
|
2024-12-12 02:05:47 -06:00
|
|
|
for all.Scan() {
|
|
|
|
check := all.Next()
|
2024-12-02 08:45:13 -06:00
|
|
|
|
2024-12-17 07:03:17 -06:00
|
|
|
if me.forge.Config.IsReadOnly(check.GetGoPath()) {
|
2024-12-13 02:21:39 -06:00
|
|
|
// 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 {
|
2024-12-16 00:19:03 -06:00
|
|
|
forceReleaseVersion(check)
|
2024-12-17 21:58:14 -06:00
|
|
|
me.found.AppendUniqueGoPath(check)
|
2024-12-16 00:19:03 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-12-17 07:03:17 -06:00
|
|
|
if argv.Protobuf && check.GetRepoType() == "protobuf" {
|
2024-12-16 00:19:03 -06:00
|
|
|
// if --protobuf, this will force upgrade each one
|
|
|
|
forceReleaseVersion(check)
|
2024-12-17 21:58:14 -06:00
|
|
|
me.found.AppendUniqueGoPath(check)
|
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
|
|
|
|
2024-12-14 23:28:53 -06:00
|
|
|
// if the repo is a go binary or plugin for a new release for
|
|
|
|
// any library version change
|
2024-12-17 07:03:17 -06:00
|
|
|
if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" {
|
2024-12-14 23:28:53 -06:00
|
|
|
// 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())
|
2024-12-16 00:19:03 -06:00
|
|
|
forceReleaseVersion(check)
|
2024-12-17 21:58:14 -06:00
|
|
|
me.found.AppendUniqueGoPath(check)
|
2024-12-02 07:00:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-12-17 13:13:15 -06:00
|
|
|
me.forge.ConfigSave()
|
2024-12-16 00:19:03 -06:00
|
|
|
}
|