add support for adding rustup targets

This commit is contained in:
softprops 2019-09-19 00:08:24 +09:00
parent be97511df1
commit 28ee781be8
4 changed files with 19 additions and 1 deletions

View File

@ -8,6 +8,9 @@ inputs:
components:
description: 'The toolchain components to install, comma-separated'
default: ''
targets:
description: 'The toolchain targets to add, comma-separated'
default: ''
runs:
using: 'node12'
main: 'lib/main.js'

View File

@ -26,6 +26,10 @@ function run() {
.split(',')
.map((component) => component.trim())
.filter((component) => component.length > 0);
const targets = core.getInput('targets')
.split(',')
.map((target) => target.trim())
.filter((target) => target.length > 0);
if (version) {
yield rustup.install();
yield exec.exec('rustup', ['default', version]);
@ -33,6 +37,9 @@ function run() {
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) {

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "node12-template-action",
"name": "setup-rust-action",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,

View File

@ -10,6 +10,10 @@ async function run() {
.split(',')
.map((component) => component.trim())
.filter((component) => component.length > 0);
const targets = core.getInput('targets')
.split(',')
.map((target) => target.trim())
.filter((target) => target.length > 0);
if(version) {
await rustup.install();
@ -19,6 +23,10 @@ async function run() {
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) {
core.setFailed(error.message);