Capture release notes of all versions above currently running one

This commit is contained in:
Justin Hawkins 2022-06-10 13:17:00 +09:30
parent 6175c77478
commit 451335e17d

View File

@ -2,6 +2,7 @@ package version
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"github.com/google/go-github/v44/github" "github.com/google/go-github/v44/github"
@ -18,7 +19,8 @@ var versionInfo struct {
Valid bool Valid bool
Tag string Tag string
} }
m sync.Mutex UpgradeReleaseNotes string
m sync.Mutex
} }
func init() { func init() {
@ -60,9 +62,17 @@ func UpdateVersionInfo() {
if len(rels) == 0 { if len(rels) == 0 {
return return
} }
versionInfo.m.Lock() versionInfo.m.Lock()
versionInfo.Remote.Tag = *rels[0].TagName versionInfo.Remote.Tag = *rels[0].TagName
versionInfo.Remote.Valid = true versionInfo.Remote.Valid = true
versionInfo.UpgradeReleaseNotes = ""
for _, r := range rels {
if semver.Compare(versionInfo.Local.Tag, *r.TagName) < 0 {
versionInfo.UpgradeReleaseNotes += fmt.Sprintf("Version: %s\n\n%s\n\n", *r.TagName, *r.Body)
}
}
versionInfo.m.Unlock() versionInfo.m.Unlock()
} }