From a8e9917736079a30924a6c6c423d2b494f4ae7be Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Mon, 16 Oct 2023 22:26:12 -0400 Subject: [PATCH] Add support for arm64 archives --- actions/action.go | 6 +++ actions/bellsoft-liberica-dependency/main.go | 46 +++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/actions/action.go b/actions/action.go index 35065b79..7236afac 100644 --- a/actions/action.go +++ b/actions/action.go @@ -65,6 +65,12 @@ func NewOutputs(uri string, latestVersion *semver.Version, additionalOutputs Out return nil, fmt.Errorf("unable to calculate source sha256\n%w", err) } outputs["source_sha256"] = sourceSha256 + } else if k == "arm64-uri" { + arm64Sha256, err := SHA256FromURI(v, mods...) + if err != nil { + return nil, fmt.Errorf("unable to calculate arm64 sha256\n%w", err) + } + outputs["arm64_sha256"] = arm64Sha256 } outputs[k] = v } diff --git a/actions/bellsoft-liberica-dependency/main.go b/actions/bellsoft-liberica-dependency/main.go index c0ae7371..745a480e 100644 --- a/actions/bellsoft-liberica-dependency/main.go +++ b/actions/bellsoft-liberica-dependency/main.go @@ -48,8 +48,7 @@ func main() { } commonStaticParams := "&version-modifier=latest" - uriStaticParams := "?arch=x86" + - "&bitness=64" + + uriStaticParams := "?bitness=64" + "&os=linux" + "&package-type=tar.gz" + commonStaticParams @@ -57,10 +56,18 @@ func main() { commonStaticParams uri := "" + armUri := "" sourceUri := "" if p == "liberica" { uri = fmt.Sprintf("https://api.bell-sw.com/v1/%s/releases"+ uriStaticParams+ + "&arch=x86"+ + "&bundle-type=%s"+ + "&version-feature=%s", + p, t, v) + armUri = fmt.Sprintf("https://api.bell-sw.com/v1/%s/releases"+ + uriStaticParams+ + "&arch=arm"+ "&bundle-type=%s"+ "&version-feature=%s", p, t, v) @@ -71,6 +78,13 @@ func main() { } else if p == "nik" { uri = fmt.Sprintf("https://api.bell-sw.com/v1/%s/releases"+ uriStaticParams+ + "&arch=x86"+ + "&bundle-type=%s"+ + "&component-version=liberica%%40%s", + p, t, v) + armUri = fmt.Sprintf("https://api.bell-sw.com/v1/%s/releases"+ + uriStaticParams+ + "&arch=arm"+ "&bundle-type=%s"+ "&component-version=liberica%%40%s", p, t, v) @@ -139,6 +153,34 @@ func main() { additionalOutputs["source"] = sources[latestVersion.Original()] } + armResp, err := http.Get(armUri) + if err != nil { + panic(fmt.Errorf("unable to get %s\n%w", armUri, err)) + } + defer armResp.Body.Close() + + if armResp.StatusCode != 200 { + panic(fmt.Errorf("unable to download %s: %d", uri, armResp.StatusCode)) + } + + var armRaw []Release + if err := json.NewDecoder(armResp.Body).Decode(&armRaw); err != nil { + panic(fmt.Errorf("unable to decode payload\n%w", err)) + } + + armVersions := make(map[string]string) + for _, r := range armRaw { + key := fmt.Sprintf("%d.%d.%d-%d", r.FeatureVersion, r.InterimVersion, r.UpdateVersion, r.BuildVersion) + if p == "nik" { + key = determineNikVersion(r, additionalOutputs) + } + armVersions[key] = r.DownloadURL + } + + if armVersions != nil { + additionalOutputs["arm64-uri"] = armVersions[latestVersion.Original()] + } + outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, additionalOutputs) if err != nil { panic(fmt.Errorf("unable to create outputs\n%w", err))