mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 21:40:01 +00:00
new: Add .cargo/target caching. (#2)
This commit is contained in:
parent
9a4d9a0018
commit
9d93ed2c80
9 changed files with 528 additions and 29 deletions
31
src/rust.ts
Normal file
31
src/rust.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
export async function extractRustVersion(toolchain: string) {
|
||||
let out = '';
|
||||
|
||||
await exec.exec('rustc', [`+${toolchain}`, '--version', '--verbose'], {
|
||||
listeners: {
|
||||
stdout(data: Buffer) {
|
||||
out += data.toString();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
out.split('\n').forEach((line) => {
|
||||
let key = '';
|
||||
|
||||
if (line.startsWith('commit-hash')) {
|
||||
key = 'rust-hash';
|
||||
} else if (line.startsWith('release')) {
|
||||
key = 'rust-version';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
const value = line.split(':')[1].trim();
|
||||
|
||||
core.saveState(key, value);
|
||||
core.setOutput(key, value);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue