guireleaser/prepareRelease.go

98 lines
2.4 KiB
Go
Raw Normal View History

package main
import (
2024-12-16 00:19:03 -06:00
"go.wit.com/lib/protobuf/gitpb"
"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 13:13:15 -06:00
me.forge.PrintReleaseReport()
2024-12-02 10:43:48 -06:00
} 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
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-12 02:05:47 -06:00
curver := check.GetMasterVersion()
2024-12-02 08:45:13 -06:00
check.SetTargetVersion(curver)
}
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)
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-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 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" {
// 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 13:13:15 -06:00
me.forge.ConfigSave()
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")
}
}
}
2024-12-16 00:19:03 -06:00
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) {
2024-12-17 07:03:17 -06:00
log.Info("go-mod-clean probably failed here. that's ok", repo.GetGoPath())
2024-12-16 00:19:03 -06:00
}
}