pantry/.github/scripts/inventory.ts

24 lines
685 B
TypeScript
Raw Normal View History

2023-12-29 11:30:54 +03:00
#!/usr/bin/env -S pkgx deno run --allow-net --allow-env=GITHUB_OUTPUT --allow-write
const [project] = Deno.args
let versions: string[] = []
for (const platform of ["linux", "darwin"]) {
for (const arch of ["x86-64", "aarch64"]) {
const url = `https://dist.pkgx.dev/${project}/${platform}/${arch}/versions.txt`
const txt = await (await fetch(url)).text()
versions.push(...txt.split("\n"))
}
}
versions = [...new Set(versions.filter(x => x.trim()))]
2023-12-29 11:28:03 +03:00
const ghout = Deno.env.get("GITHUB_OUTPUT")
if (ghout) {
const json = JSON.stringify(versions)
Deno.writeTextFileSync(ghout, `versions=${json}`, {append: true})
} else {
console.log(JSON.stringify(versions))
}