Merge pull request #15886 from spowelljr/useCommonFunc
CI: Make common func to get stable versionpull/15889/head
commit
b522747fea
|
@ -22,7 +22,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -53,7 +52,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get cloud-spanner-emulator stable version
|
||||
stable, err := cloudSpannerEmulatorVersion(ctx, "GoogleCloudPlatform", "cloud-spanner-emulator")
|
||||
stable, err := update.StableVersion(ctx, "GoogleCloudPlatform", "cloud-spanner-emulator")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get cloud-spanner-emulator stable version: %v", err)
|
||||
}
|
||||
|
@ -68,13 +67,3 @@ func main() {
|
|||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// cloudSpannerEmulatorVersion returns stable version in semver format.
|
||||
func cloudSpannerEmulatorVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get Golint version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"os/exec"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -38,7 +37,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get Docsy stable version
|
||||
stable, err := docsyVersion(ctx, "google", "docsy")
|
||||
stable, err := update.StableVersion(ctx, "google", "docsy")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get Doscy stable version: %v", err)
|
||||
}
|
||||
|
@ -48,13 +47,3 @@ func main() {
|
|||
klog.Fatalf("failed to update docsy commit: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// docsyVersion returns stable version in semver format.
|
||||
func docsyVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get Docsy version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -53,22 +52,12 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get gh stable version
|
||||
stable, err := ghVersion(ctx, "cli", "cli")
|
||||
stable, err := update.StableVersion(ctx, "cli", "cli")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get gh stable version: %v", err)
|
||||
}
|
||||
data := Data{StableVersion: stable}
|
||||
data := Data{StableVersion: strings.TrimPrefix(stable, "v")}
|
||||
klog.Infof("gh stable version: %s", data.StableVersion)
|
||||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// ghVersion returns stable version in semver format.
|
||||
func ghVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get gh version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimPrefix(stable.Tag, "v"), nil
|
||||
}
|
||||
|
|
|
@ -123,3 +123,11 @@ func GHReleases(ctx context.Context, owner, repo string) (stable, latest, edge R
|
|||
|
||||
return stable, latest, edge, fmt.Errorf("wasn't able to find commit for releases")
|
||||
}
|
||||
|
||||
func StableVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
stable, _, _, err := GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -52,7 +51,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get Golint stable version
|
||||
stable, err := golintVersion(ctx, "golangci", "golangci-lint")
|
||||
stable, err := update.StableVersion(ctx, "golangci", "golangci-lint")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get Golint stable version: %v", err)
|
||||
}
|
||||
|
@ -61,13 +60,3 @@ func main() {
|
|||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// golintVersion returns stable version in semver format.
|
||||
func golintVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get Golint version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -72,7 +71,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get gopogh stable version from https://github.com/medyagh/gopogh
|
||||
stable, err := gopoghVersion(ctx, "medyagh", "gopogh")
|
||||
stable, err := update.StableVersion(ctx, "medyagh", "gopogh")
|
||||
if err != nil || stable == "" {
|
||||
klog.Fatalf("Unable to get gopogh stable version: %v", err)
|
||||
}
|
||||
|
@ -81,13 +80,3 @@ func main() {
|
|||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// gopoghVersion returns gopogh stable version in semver format.
|
||||
func gopoghVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get gopogh version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -58,7 +57,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get gotestsum stable version from https://github.com/gotestyourself/gotestsum
|
||||
stable, err := gotestsumVersion(ctx, "gotestyourself", "gotestsum")
|
||||
stable, err := update.StableVersion(ctx, "gotestyourself", "gotestsum")
|
||||
if err != nil || stable == "" {
|
||||
klog.Fatalf("Unable to get gotestsum stable version: %v", err)
|
||||
}
|
||||
|
@ -67,13 +66,3 @@ func main() {
|
|||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// gotestsumVersion returns gotestsum stable version in semver format.
|
||||
func gotestsumVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get gotestsum version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
@ -52,7 +51,7 @@ func main() {
|
|||
defer cancel()
|
||||
|
||||
// get Hugo stable version
|
||||
stable, err := hugoVersion(ctx, "gohugoio", "hugo")
|
||||
stable, err := update.StableVersion(ctx, "gohugoio", "hugo")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get Hugo stable version: %v", err)
|
||||
}
|
||||
|
@ -61,13 +60,3 @@ func main() {
|
|||
|
||||
update.Apply(schema, data)
|
||||
}
|
||||
|
||||
// hugoVersion returns stable version in semver format.
|
||||
func hugoVersion(ctx context.Context, owner, repo string) (string, error) {
|
||||
// get Hugo version from GitHub Releases
|
||||
stable, _, _, err := update.GHReleases(ctx, owner, repo)
|
||||
if err != nil || !semver.IsValid(stable.Tag) {
|
||||
return "", err
|
||||
}
|
||||
return stable.Tag, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue