-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (33 loc) · 820 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const core = require("@actions/core");
const fs = require("fs");
try {
let file = core.getInput("file");
let suffix = core.getInput("suffix");
let build = core.getInput("build");
let offset = core.getInput("offset");
let nextVersion = yyyymmdd() + ".";
let wantedBuild = parseInt(build);
if (offset) wantedBuild = parseInt(build) + parseInt(offset);
nextVersion += wantedBuild;
if (suffix) {
nextVersion = nextVersion + "-" + suffix;
}
fs.writeFileSync(file, nextVersion, "utf8");
core.setOutput("version", nextVersion);
} catch (error) {
core.setFailed(error.message);
}
function yyyymmdd() {
function twoDigit(n) {
return (n < 10 ? "0" : "") + n;
}
var now = new Date();
return (
"" +
now.getFullYear() +
"." +
twoDigit(now.getMonth() + 1) +
"." +
twoDigit(now.getDate())
);
}