Skip to content

Commit

Permalink
Add support for arm64 archives
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonydahanne committed Oct 17, 2023
1 parent eabda4f commit a8e9917
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions actions/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
46 changes: 44 additions & 2 deletions actions/bellsoft-liberica-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,26 @@ func main() {
}

commonStaticParams := "&version-modifier=latest"
uriStaticParams := "?arch=x86" +
"&bitness=64" +
uriStaticParams := "?bitness=64" +
"&os=linux" +
"&package-type=tar.gz" +
commonStaticParams
sourceUriStaticParams := "?package-type=src.tar.gz" +
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)
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit a8e9917

Please sign in to comment.