Use toolchain install instead of multiple commands
This commit is contained in:
parent
1cba3cf86a
commit
43013c6795
11
lib/main.js
11
lib/main.js
@ -32,14 +32,11 @@ function run() {
|
|||||||
.filter((target) => target.length > 0);
|
.filter((target) => target.length > 0);
|
||||||
if (version) {
|
if (version) {
|
||||||
yield rustup.install();
|
yield rustup.install();
|
||||||
|
yield exec.exec('rustup', ['toolchain', 'install', version,
|
||||||
|
...(components.length > 0 ? ['-c', ...components] : []),
|
||||||
|
...(targets.length > 0 ? ['-t', ...targets] : []),
|
||||||
|
]);
|
||||||
yield exec.exec('rustup', ['default', version]);
|
yield exec.exec('rustup', ['default', version]);
|
||||||
yield exec.exec('rustup', ['update', version]);
|
|
||||||
for (let component of components) {
|
|
||||||
yield exec.exec('rustup', ['component', 'add', component]);
|
|
||||||
}
|
|
||||||
for (let target of targets) {
|
|
||||||
yield exec.exec('rustup', ['target', 'add', target]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
@ -30,6 +30,11 @@ function install() {
|
|||||||
core.debug('rustup is located under: ' + toolPath);
|
core.debug('rustup is located under: ' + toolPath);
|
||||||
core.addPath(path.join(toolPath, 'bin'));
|
core.addPath(path.join(toolPath, 'bin'));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// update the GitHub managed VM version of rustup
|
||||||
|
// to leverage newer features like "latest latest compatible nightly"
|
||||||
|
yield exec.exec('rustup', ['self', 'update']);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.install = install;
|
exports.install = install;
|
||||||
|
20
src/main.ts
20
src/main.ts
@ -6,10 +6,12 @@ import * as os from 'os';
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput('rust-version');
|
const version = core.getInput('rust-version');
|
||||||
|
|
||||||
const components = core.getInput('components')
|
const components = core.getInput('components')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((component) => component.trim())
|
.map((component) => component.trim())
|
||||||
.filter((component) => component.length > 0);
|
.filter((component) => component.length > 0);
|
||||||
|
|
||||||
const targets = core.getInput('targets')
|
const targets = core.getInput('targets')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((target) => target.trim())
|
.map((target) => target.trim())
|
||||||
@ -17,16 +19,16 @@ async function run() {
|
|||||||
|
|
||||||
if(version) {
|
if(version) {
|
||||||
await rustup.install();
|
await rustup.install();
|
||||||
|
|
||||||
|
await exec.exec(
|
||||||
|
'rustup',
|
||||||
|
['toolchain', 'install', version,
|
||||||
|
...(components.length > 0 ? ['-c', ...components] : []),
|
||||||
|
...(targets.length > 0 ? ['-t', ...targets] : []),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
await exec.exec('rustup', ['default', version]);
|
await exec.exec('rustup', ['default', version]);
|
||||||
await exec.exec('rustup', ['update', version]);
|
|
||||||
|
|
||||||
for(let component of components) {
|
|
||||||
await exec.exec('rustup', ['component', 'add', component]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(let target of targets) {
|
|
||||||
await exec.exec('rustup', ['target', 'add', target]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
Loading…
Reference in New Issue
Block a user