-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
43 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,76 @@ | ||
#!/usr/bin/env -S pkgx deno run -A | ||
|
||
import { hooks, utils } from "pkgx" | ||
import { isString, isArray } from "is-what" | ||
|
||
const pkg = utils.pkg.parse(Deno.args[0]) | ||
|
||
const rv = {} as Record<string, any> | ||
for (const platform of await get_platforms(pkg)) { | ||
const key = platform.replace('/', '+') | ||
rv[key] = get_matrix(platform) | ||
} | ||
|
||
const ghout = Deno.env.get("GITHUB_OUTPUT") | ||
if (ghout) { | ||
const json = JSON.stringify(Object.values(rv)) | ||
Deno.writeTextFileSync(ghout, `matrix=${json}`, {append: true}) | ||
} else { | ||
const json = JSON.stringify(rv, null, 2) | ||
console.log(json) | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////// | ||
|
||
//TODO should be in libpkgx! | ||
async function get_platforms(pkg: {project: string}) { | ||
let { platforms } = await hooks.usePantry().project(pkg).yaml() | ||
if (!platforms) return ["linux/x86-64", "linux/aarch64", "darwin/x86-64", "darwin/aarch64"] | ||
if (isString(platforms)) platforms = [platforms] | ||
if (!isArray(platforms)) throw new Error(`invalid platform node: ${platforms}`) | ||
const rv = [] | ||
for (const platform of platforms) { | ||
if (platform.match(/^(linux|darwin)\/(aarch64|x86-64)$/)) rv.push(platform) | ||
else if (platform.match(/^(linux|darwin)$/)) rv.push(`${platform}/x86-64`, `${platform}/aarch64`) | ||
else throw new Error(`invalid platform: ${platform}`) | ||
} | ||
return rv | ||
} | ||
|
||
function get_matrix(platform: string) { | ||
const name = platform.replace('/', '+') | ||
switch (platform) { | ||
case 'darwin/aarch64': { | ||
const os = ["self-hosted", "macOS", "ARM64"] | ||
return { | ||
os, name, | ||
"test-os": [os], | ||
"test-container": [null], | ||
tinyname: "²" | ||
}} | ||
case 'darwin/x86-64': { | ||
const os = ["self-hosted", "macOS", "X64"] | ||
return { | ||
os, name, | ||
"test-os": ["macos-11", "macos-12"], | ||
"test-container": [null], | ||
tinyname: "x64" | ||
}} | ||
case 'linux/x86-64': { | ||
const os = {group: "linux-x86-64"} | ||
return { | ||
os, name, | ||
container: "debian:buster-slim", | ||
"test-os": [os], | ||
"test-container": ["debian:buster-slim", "ubuntu", "archlinux"], | ||
tinyname: "Lnx·x64" | ||
}} | ||
case 'linux/aarch64': { | ||
const os = ["self-hosted", "linux", "ARM64"] | ||
return { | ||
os, name, | ||
"test-os": [os], | ||
"test-container": [null], | ||
tinyname: "Lnx·ARM64" | ||
}}} | ||
} |
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
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
echo "pkgs=$var" >> $GITHUB_OUTPUT | ||
id: divide | ||
deploy: | ||
pkgit: | ||
needs: divide | ||
strategy: | ||
matrix: | ||
|
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