Skip to content

Commit

Permalink
Support arch variant to download xgo (#238)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max and crazy-max authored Apr 29, 2022
1 parent 70b38a8 commit 2b8be08
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

32 changes: 30 additions & 2 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,36 @@ export async function getXgo(version: string): Promise<Xgo> {
}

const getFilename = (semver: string): string => {
const platform: string = osPlat == 'win32' ? 'windows' : osPlat;
const arch: string = osArch == 'x64' ? 'x86_64' : 'i386';
let platform, arch: string;
switch (osPlat) {
case 'win32': {
platform = 'windows';
break;
}
default: {
platform = osPlat;
break;
}
}
switch (osArch) {
case 'x64': {
arch = 'x86_64';
break;
}
case 'x32': {
arch = 'i386';
break;
}
case 'arm': {
const arm_version = (process.config.variables as any).arm_version;
arch = arm_version ? 'armv' + arm_version : 'arm';
break;
}
default: {
arch = osArch;
break;
}
}
const ext: string = osPlat == 'win32' ? '.zip' : '.tar.gz';
return util.format('xgo_%s_%s_%s%s', semver, platform, arch, ext);
};
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ async function run(): Promise<void> {
process.chdir(workingDir);
await exec.exec(xgo.path, args);

core.info('Fixing perms');
core.startGroup(`Fixing perms`);
const uid = parseInt(child_process.execSync(`id -u`, {encoding: 'utf8'}).trim());
const gid = parseInt(child_process.execSync(`id -g`, {encoding: 'utf8'}).trim());
await exec.exec('sudo', ['chown', '-R', `${uid}:${gid}`, workingDir]);
core.endGroup();
} catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit 2b8be08

Please sign in to comment.