generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 1.25 KB
/
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
41
42
43
44
45
const core = require("@actions/core");
const getLatestTag = require("./getLatestTag");
async function run() {
try {
// -- Read Inputs --
const repository = core.getInput("repository", { required: true });
const repoParts = repository.split("/");
if (repoParts.length !== 2) {
throw `Invalid repository "${repository}" (needs to have one slash, i.e. 'owner/repo')`;
}
const [owner, repo] = repoParts;
const token = core.getInput("token") || null;
const prefix = core.getInput("prefix") || "";
const regex = core.getInput("regex") || null;
const releasesOnly = core.getBooleanInput("releases-only");
// It's somewhat safe to assume that the most recenly created release is actually latest.
const sortTagsDefault = releasesOnly ? "false" : "true";
const sortTags =
(core.getInput("sort-tags") || sortTagsDefault).toLowerCase() === "true";
const excludes = (core.getInput("excludes") || "").split(",");
// -- Perform Task --
const tag = await getLatestTag(
token,
owner,
repo,
releasesOnly,
prefix,
regex,
sortTags,
excludes
);
// -- Write Outputs --
core.setOutput("tag", tag);
} catch (error) {
core.setFailed(error);
}
}
run();