Skip to content

Commit f41fffe

Browse files
committed
Support multiple platforms.
1 parent ef63735 commit f41fffe

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

index.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11

2-
const {debug} = require('@actions/core');
2+
const os = require('os');
3+
const core = require('@actions/core');
34
const {exec} = require('@actions/exec');
45

6+
const Install = {
7+
linux: async function() {
8+
try {
9+
core.debug("Adding repositories...");
10+
await exec('sudo', ['apt-add-repository', '-y', 'ppa:ubuntu-toolchain-r/test']);
11+
12+
core.debug("Fetching packages...");
13+
await exec('sudo', ['apt-get', '-yq', '--no-install-suggests', '--no-install-recommends', 'install', 'clang', 'libc++-dev', 'libc++abi-dev', 'nasm']);
14+
} catch (error) {
15+
core.setFailed(error.message);
16+
}
17+
}
18+
};
19+
520
async function main() {
6-
try {
7-
debug("Adding repositories...");
8-
await exec('sudo', ['apt-add-repository', '-y', 'ppa:ubuntu-toolchain-r/test']);
9-
10-
debug("Fetching packages...");
11-
await exec('sudo', ['apt-get', '-yq', '--no-install-suggests', '--no-install-recommends', 'install', 'clang', 'libc++-dev', 'libc++abi-dev', 'nasm']);
12-
} catch (error) {
13-
core.setFailed(error.message);
21+
let platform = os.platform();
22+
let install = Install[platform];
23+
24+
if (install) {
25+
await install();
26+
} else {
27+
core.debug(`Nothing to do for ${platform}!`);
1428
}
1529
}
1630

17-
main()
31+
main();

0 commit comments

Comments
 (0)