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