package main import ( "go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/gitpb" "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() me.forge.PrintReleaseReport(me.found) } else { log.Info("setAllBranchesToMaster() failed") } // 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"}) if !runGoClean(repo, "--restore") { log.Info("go-mod-clean probably failed here. that's ok", repo.GetGoPath()) // os.Exit(-1) } } func rePrepareRelease() { // reload the config me.forge = forgepb.Init() me.found = new(gitpb.Repos) // blank all the target versions incase they were saved in the config .pb file all := me.forge.Repos.SortByFullPath() for all.Scan() { check := all.Next() // set the target version to the current master version lastTag := check.GetLastTag() check.SetTargetVersion(lastTag) 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) } } all = me.forge.Repos.SortByFullPath() for all.Scan() { check := all.Next() if me.forge.Config.IsReadOnly(check.GetGoPath()) { // can't release readonly repos continue } // if master != lastTag, always increment master := check.GetMasterVersion() lastTag := check.GetLastTag() if master != lastTag { forceReleaseVersion(check) me.found.AppendUniqueGoPath(check) continue } if argv.Protobuf && check.GetRepoType() == "protobuf" { // if --protobuf, this will force upgrade each one forceReleaseVersion(check) me.found.AppendUniqueGoPath(check) continue } // if the repo is a go binary or plugin for a new release for // any library version change if check.GetRepoType() == "binary" || check.GetRepoType() == "plugin" { // 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()) forceReleaseVersion(check) me.found.AppendUniqueGoPath(check) } } me.forge.ConfigSave() }