comment the logic of the action

This commit is contained in:
cmario92 2021-07-01 21:17:11 +03:00
parent 44d90648f6
commit 03c10b2a9d
1 changed files with 22 additions and 3 deletions

View File

@ -28,26 +28,36 @@ Toolkit.run(async (tools) => {
return;
}
// input wordings for MAJOR, MINOR, PATCH, PRE-RELEASE
const majorWords = process.env['INPUT_MAJOR-WORDING'].split(',');
const minorWords = process.env['INPUT_MINOR-WORDING'].split(',');
const patchWords = process.env['INPUT_PATCH-WORDING'].split(',');
const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',');
// get default version bump
let version = process.env.INPUT_DEFAULT;
let foundWord = null;
// get the pre-release prefix specified in action
let preid = process.env.INPUT_PREID;
// case: if wording for MAJOR found
if (
messages.some(
(message) => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some((word) => message.includes(word)),
)
) {
version = 'major';
} else if (messages.some((message) => minorWords.some((word) => message.includes(word)))) {
}
// case: if wording for MINOR found
else if (messages.some((message) => minorWords.some((word) => message.includes(word)))) {
version = 'minor';
} else if (messages.some((message) => patchWords.some((word) => message.includes(word)))) {
}
// case: if wording for PATCH found
else if (messages.some((message) => patchWords.some((word) => message.includes(word)))) {
version = 'patch';
} else if (
}
// case: if wording for PRE-RELEASE found
else if (
messages.some((message) =>
preReleaseWords.some((word) => {
if (message.includes(word)) {
@ -63,16 +73,25 @@ Toolkit.run(async (tools) => {
version = 'prerelease';
}
// case: if default=prerelease, but rc-wording is also set
// then unset it and do not run, when no rc words found in message
if (version === 'prerelease' && !messages.some((message) => preReleaseWords.some((word) => message.includes(word)))) {
version = null;
}
// case: if default=prerelease, but rc-wording is NOT set
if (version === 'prerelease' && preid) {
version = 'prerelease';
version = `${version} --preid=${preid}`;
}
// case: if nothing of the above matches
if (version === null) {
tools.exit.success('No version keywords found, skipping bump.');
return;
}
// GIT logic
try {
const current = pkg.version.toString();
// set git user