Skip to content

Commit

Permalink
Action fixes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Daniel Mikusa committed May 10, 2022
1 parent ce70963 commit eb306ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion actions/alibaba-dragonwell-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion actions/foojay-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}

Expand Down
12 changes: 4 additions & 8 deletions actions/graalvm-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
Expand Down Expand Up @@ -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
}

0 comments on commit eb306ab

Please sign in to comment.