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

Add support for Github Runner platforms and architectures other than linux-x64 #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 14 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"author": "Ivan Voskoboinyk <ivan@voskoboinyk.com>",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/core": "^1.11.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
"@types/jest": "^29.5.11",
Expand Down
22 changes: 17 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ const ARCH = 'amd64'
const DEFAULT_VERSION = 'latest'
const ERROR_MESSAGE = 'Failed to install goss'

const ARCH_MAP: { [arch: string]: string } = {
ia32: '386',
x64: 'amd64'
}

interface CommandsMap {
[command: string]: string
}

async function getUrls(version: string): Promise<CommandsMap> {
async function getUrls(
platform: string,
version: string
): Promise<CommandsMap> {
if (version === 'latest') {
const response = await fetch(
'https://api.github.com/repos/goss-org/goss/releases/latest'
Expand All @@ -22,11 +30,11 @@ async function getUrls(version: string): Promise<CommandsMap> {

const latest = (await response.json()) as { tag_name: string }

return getUrls(latest.tag_name)
return getUrls(platform, latest.tag_name)
}

return {
goss: `https://github.com/goss-org/goss/releases/download/${version}/goss-linux-${ARCH}`,
goss: `https://github.com/goss-org/goss/releases/download/${version}/goss-${platform}`,
dgoss: `https://raw.githubusercontent.com/goss-org/goss/${version}/extras/dgoss/dgoss`,
dcgoss: `https://raw.githubusercontent.com/goss-org/goss/${version}/extras/dcgoss/dcgoss`,
kgoss: `https://raw.githubusercontent.com/goss-org/goss/${version}/extras/kgoss/kgoss`
Expand Down Expand Up @@ -77,7 +85,7 @@ async function cache(
): Promise<CommandsMap> {
const results = await Promise.all(
Object.entries(paths).map(async ([command, path]) => {
const cached = await tc.cacheFile(path, command, command, version, ARCH)
const cached = await tc.cacheFile(path, command, command, version)
return { [command]: cached }
})
)
Expand All @@ -94,7 +102,11 @@ async function run(): Promise<void> {
try {
const version: string =
core.getInput('version', { required: false }) || DEFAULT_VERSION
const urls = await getUrls(version)
const platform = `${
core.platform.isWindows ? 'windows' : core.platform.platform
}-${ARCH_MAP[core.platform.arch] || core.platform.arch}`

const urls = await getUrls(platform, version)
const missing = restore(urls, version)
const downloaded = await download(missing)
await chmod(downloaded, '755')
Expand Down