From 03c10b2a9d965ec8a32ab4e153810c1cdfeb102e Mon Sep 17 00:00:00 2001 From: cmario92 Date: Thu, 1 Jul 2021 21:17:11 +0300 Subject: [PATCH] comment the logic of the action --- index.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index a6f2a99..faacb74 100644 --- a/index.js +++ b/index.js @@ -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