generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (22 loc) · 851 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
const core = require('@actions/core');
const setVersion = require('./set-version');
// most @actions toolkit packages have async methods
async function run() {
try {
const cargoFile = core.getInput('cargoFile');
const version = core.getInput('version');
const buildNumberOnly = core.getInput('buildNumberOnly');
const overwriteCargoFile = core.getInput('overwriteCargoFile');
core.info(`Running with ${cargoFile} ${version} ${buildNumberOnly}`);
const result = setVersion(fs.readFileSync(cargoFile).toString(), version, buildNumberOnly);
if (overwriteCargoFile) {
fs.writeFileSync(cargoFile, result.content);
}
core.setOutput('content', result.content);
core.setOutput('version', result.version);
} catch (error) {
core.setFailed(error.message);
}
}
run();