Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change foojay update checker to include the architecture #1642

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 as build-stage
FROM golang:1.22 as build-stage

WORKDIR /src
ENV GO111MODULE=on CGO_ENABLED=0
Expand Down
26 changes: 21 additions & 5 deletions actions/foojay-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,28 @@ var client *http.Client = http.DefaultClient
func main() {
inputs := actions.NewInputs()

// See list of distro's -> https://api.foojay.io/swagger-ui#/default/getDistributionsV2
// Needs to be in this list
// (aoj, aoj_openj9, bisheng, corretto, dragonwell, graalvm_ce8, graalvm_ce11, graalvm_ce16, graalvm_ce17, graalvm_ce19, graalvm_ce20, graalvm_community, graalvm, jetbrains, kona, liberica, liberica_native, mandrel, microsoft, ojdk_build, openlogic, oracle, oracle_open_jdk, redhat, sap_machine, semeru, semeru_certified, temurin, trava, zulu, zulu_prime)
// https://api.foojay.io/swagger-ui#/default/getPackagesV3
d, ok := inputs["distro"]
if !ok {
panic(fmt.Errorf("distro must be specified"))
}

arch, ok := inputs["arch"]
if !ok {
arch = "x64"
}

// Needs to be in this list
// (aarch32, aarch64, amd64, arm, arm32, arm64, mips, ppc, ppc64el, ppc64le, ppc64, riscv64, s390, s390x, sparc, sparcv9, x64, x86-64, x86, i386, i486, i586, i686, x86-32)
// https://api.foojay.io/swagger-ui#/default/getPackagesV3
if arch == "amd64" {
arch = "x64"
} else if arch == "arm64" {
arch = "aarch64"
}

distros, err := LoadDistros()
if err != nil {
panic(fmt.Errorf("unable to load distros\n%w", err))
Expand Down Expand Up @@ -73,7 +89,7 @@ func main() {
panic(fmt.Errorf("version cannot be parsed\n%w", err))
}

versions := LoadPackages(d, t, v)
versions := LoadPackages(d, t, v, arch)

latestVersion, err := versions.GetLatestVersion(inputs)
if err != nil {
Expand All @@ -96,18 +112,18 @@ func main() {
outputs.Write()
}

func LoadPackages(d string, t string, v int) actions.Versions {
func LoadPackages(d string, t string, v int, a string) actions.Versions {
uri := fmt.Sprintf(
"https://api.foojay.io/disco/v3.0/packages?"+
"distro=%s&"+
"architecture=x64&"+
"architecture=%s&"+
"archive_type=tar.gz&"+
"package_type=%s&"+
"operating_system=linux&"+
"lib_c_type=glibc&"+
"javafx_bundled=false&"+
"version=%d..%%3C%d", // 11..<12
url.PathEscape(d), t, v, v+1)
url.PathEscape(d), a, t, v, v+1)

request, err := http.NewRequest("GET", uri, nil)
if err != nil {
Expand Down