-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (49 loc) · 1.72 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const core = require('@actions/core');
const release = require('conventional-github-releaser');
// most @actions toolkit packages have async methods
async function run() {
try {
core.info(`Starting Conventional GitHub Release Action.`);
const auth = {
url: 'https://api.github.com/',
type: "oauth",
token: core.getInput('token')
};
if (auth.token === undefined) {
core.setFailed(`The GitHub Token could not be detected (from the token action input).`);
return;
}
const tokenLength = auth.token.length;
if (tokenLength < 40) {
core.setFailed(`The supplied GitHub Token (from the token action input) had a length of ${tokenLength} but it should be at least have a length of 40.`);
return;
}
const changelogOpts = {
preset: core.getInput('preset'),
releaseCount: parseInt(core.getInput('release-count'))
};
/*
const repository = process.env.GITHUB_REPOSITORY;
core.info(`Repository detected as ${repository}.`);
const i = repository.indexOf("/");
const context = {
owner: repository.substring(0, i),
repository: repository.substring(i + 1)
}
*/
core.info(`Attempting Conventional GitHub Release.`);
release(auth, changelogOpts, undefined, {}, undefined, undefined, function(err, responses) {
if (err !== null) {
core.setFailed(`An error occurred creating the release: ${err}`);
return;
}
core.info(`"Successfully Created the GitHub Release`);
for (const response of responses) {
core.debug(`Response: ${response}`);
}
});
} catch (error) {
core.setFailed(`An exception occurred calling the release module: ${error.message}`);
}
}
run();