-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jan Martens <[email protected]>
- Loading branch information
Showing
4 changed files
with
435 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
interface Release { | ||
assets: { | ||
linux: { | ||
deb: string[]; | ||
rpm: string[]; | ||
binary: string[]; | ||
docker: string[]; | ||
}; | ||
darwin: { | ||
binary: string[]; | ||
}; | ||
freebsd: { | ||
binary: string[]; | ||
}; | ||
netbsd: { | ||
binary: string[]; | ||
}; | ||
openbsd: { | ||
binary: string[]; | ||
}; | ||
windows: { | ||
binary: string[]; | ||
}; | ||
}; | ||
} | ||
|
||
interface Releases { | ||
[key: string]: Release; | ||
} | ||
|
||
interface GHRelease { | ||
tag_name: string; | ||
assets: GHAsset[]; | ||
} | ||
|
||
interface GHAsset { | ||
browser_download_url: string; | ||
} | ||
|
||
export function GetReleases(response): Releases { | ||
const releases: GHRelease[] = response as GHRelease[]; | ||
const result: Releases = {}; | ||
|
||
releases.forEach((r) => { | ||
const version = r.tag_name; | ||
|
||
var release = { | ||
assets: { | ||
linux: { | ||
deb: [], | ||
rpm: [], | ||
binary: [], | ||
docker: [], | ||
}, | ||
darwin: { | ||
binary: [], | ||
}, | ||
freebsd: { | ||
binary: [], | ||
}, | ||
netbsd: { | ||
binary: [], | ||
}, | ||
openbsd: { | ||
binary: [], | ||
}, | ||
windows: { | ||
binary: [], | ||
}, | ||
}, | ||
} as Release; | ||
for (var a of r.assets) { | ||
if (a.browser_download_url.includes("windows")) { | ||
release.assets.windows.binary.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("openbsd")) { | ||
release.assets.openbsd.binary.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("netbsd")) { | ||
release.assets.netbsd.binary.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("freebsd")) { | ||
release.assets.freebsd.binary.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("darwin")) { | ||
release.assets.darwin.binary.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("docker")) { | ||
release.assets.linux.docker.push(a.browser_download_url); | ||
// docker urls also contain "linux", so contiune if we find it | ||
continue; | ||
} | ||
if (a.browser_download_url.includes("rpm")) { | ||
release.assets.linux.rpm.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("deb")) { | ||
release.assets.linux.deb.push(a.browser_download_url); | ||
} | ||
if (a.browser_download_url.includes("linux")) { | ||
release.assets.linux.binary.push(a.browser_download_url); | ||
} | ||
} | ||
result[version] = release; | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
export function AssetArchitecture(url: string): string { | ||
if (url.includes("amd64")) { | ||
return "amd64"; | ||
} | ||
if (url.includes("arm64")) { | ||
return "arm64"; | ||
} | ||
if (url.includes("armhf")) { | ||
return "armhf"; | ||
} | ||
if (url.includes("armv7hl")) { | ||
return "armv7hl"; | ||
} | ||
if (url.includes("arm")) { | ||
return "arm"; | ||
} | ||
if (url.includes("riscv64")) { | ||
return "riscv64"; | ||
} | ||
if (url.includes("aarch64")) { | ||
return "aarch64"; | ||
} | ||
if (url.includes("x86_64")) { | ||
return "x86_64"; | ||
} | ||
return "<none>"; | ||
} | ||
|
||
export function OsPrettyPrint(name: string): string { | ||
switch (name) { | ||
case "linux": | ||
return "Linux"; | ||
case "darwin": | ||
return "MacOS"; | ||
case "freebsd": | ||
return "FreeBSD"; | ||
case "openbsd": | ||
return "OpenBSD"; | ||
case "netbsd": | ||
return "NetBSD"; | ||
case "windows": | ||
return "Windows"; | ||
} | ||
return ""; | ||
} |
Oops, something went wrong.