new: Add .cargo/target caching. (#2)

This commit is contained in:
Miles Johnson 2023-04-17 15:20:40 -07:00 committed by GitHub
parent 9a4d9a0018
commit 9d93ed2c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 528 additions and 29 deletions

31
src/rust.ts Normal file
View 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);
});
}