From eb306ab8d0257a24985e3ccc0f6b33608d355230 Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Tue, 10 May 2022 11:00:50 -0400 Subject: [PATCH] Action fixes 1. Not a bug, but for code clarity consistently use 'version' in dragonwell action 2. Panic when we can't parse a version from the Foojay API. This should not happen, just printing could result in missing errors. 3. Modify graalvm to pull the Java version even for native image installable downloads. This is consistent with past behavior. Signed-off-by: Daniel Mikusa --- actions/alibaba-dragonwell-dependency/main.go | 2 +- actions/foojay-dependency/main.go | 2 +- actions/graalvm-dependency/main.go | 12 ++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/actions/alibaba-dragonwell-dependency/main.go b/actions/alibaba-dragonwell-dependency/main.go index e0b3714f..8e152796 100644 --- a/actions/alibaba-dragonwell-dependency/main.go +++ b/actions/alibaba-dragonwell-dependency/main.go @@ -73,7 +73,7 @@ func main() { for _, a := range r.Assets { if globRegex.MatchString(*a.Name) { version := tag[1] - if strings.HasPrefix(tag[1], "8u") { + if strings.HasPrefix(version, "8u") { version = fmt.Sprintf("8.0.%s", strings.TrimLeft(version, "8u")) } versions[version] = *a.BrowserDownloadURL diff --git a/actions/foojay-dependency/main.go b/actions/foojay-dependency/main.go index 4dbc7951..94f05aea 100644 --- a/actions/foojay-dependency/main.go +++ b/actions/foojay-dependency/main.go @@ -146,7 +146,7 @@ func LoadPackages(d string, t string, v int) actions.Versions { } versions[version] = LoadDownloadURI(result.Links.URI) } else { - fmt.Println(result.JavaVersion, "failed to parse") + panic(fmt.Errorf(result.JavaVersion, "failed to parse")) } } diff --git a/actions/graalvm-dependency/main.go b/actions/graalvm-dependency/main.go index d219142f..e10164f4 100644 --- a/actions/graalvm-dependency/main.go +++ b/actions/graalvm-dependency/main.go @@ -111,9 +111,7 @@ func main() { url := versions[latestVersion.Original()] - if productType == JDKProductType { - latestVersion = semver.MustParse(GetVersion(url)) - } + latestVersion = semver.MustParse(GetVersion(url)) outputs, err := actions.NewOutputs(url, latestVersion, nil) if err != nil { @@ -138,6 +136,9 @@ func main() { } func GetVersion(uri string) string { + // for native-image installer, we convert the URL to the graalvm-ce download URL to fetch the version + uri = strings.Replace(strings.Replace(uri, ".jar", ".tar.gz", 1), "native-image-installable-svm-", "graalvm-ce-", 1) + resp, err := http.Get(uri) if err != nil { panic(fmt.Errorf("unable to get %s\n%w", uri, err)) @@ -186,8 +187,3 @@ func GetVersion(uri string) string { panic(fmt.Errorf("unable to find file that matches %s", re.String())) } - -type Holder struct { - Assets []*github.ReleaseAsset - URI string -}