diff --git a/action.yml b/action.yml index 7d25d05..da597f8 100644 --- a/action.yml +++ b/action.yml @@ -14,7 +14,9 @@ inputs: prefix: required: false description: |- - One or more newline deliminated prefixes for returned tags. + One or more whitespace or comma deliminated prefixes for returned tags. + Use of separators besides new lines is deprecated but for now still + supported. All permutations of prefixes and suffixes are considered. default: "" diff --git a/src/index.js b/src/index.js index bda6df7..93ef2e5 100644 --- a/src/index.js +++ b/src/index.js @@ -26,9 +26,14 @@ function checkAgainstRegex(name, regexAllowed) { } function expandPrefixSuffix(prefix, suffix, tag) { - // Adds all permutations of prefixes and suffixes to a tag, where suffix and - // prefix could be a single prefix or a comma/whitespace separated list. - let prefixes = [...new Set(prefix.split(/\n/))]; + // Adds all permutations of prefixes and suffixes to a tag, where prefix could + // be a single prefix or a comma/whitespace separated list of prefixes, and + // suffix could be a single suffix or a new line separated list of suffixes. + let prefixes = [...new Set(prefix.split(/\s|,/).filter(Boolean))]; + if (prefixes.length == 0) { + // the permutation logic below requires at least one element + prefixes.push(""); + } let suffixes = [...new Set(suffix.split(/\n/))]; return prefixes.flatMap((p) => suffixes.map((s) => `${p}${tag}${s}`)); } @@ -181,19 +186,27 @@ async function run() { const defaultTag = core.getInput("defaultTag"); const branchRegex = core.getInput("branchRegex"); - function check_prefix_suffix(input_name, input_value) { + function check_prefix_suffix(input_name, input_value, just_warn) { // Partial check that prefix and suffix inputs are OK // Check if there is any whitespace characters besides new lines or // commas. const re = new RegExp(/^[^\s,]+$/g); if (re.test(input_value.replace("\n", ""))) { - throw new Error( - `Input ${input_name} invalid, contains either comma or whitespace besides the new line separator`, - ); + if (just_warn) { + core.warning( + "Input 'prefix' will soon require the use of new lines to separate prefixes, trim away your other whitespace and commas.", + ); + } else { + throw new Error( + `Input ${input_name} invalid, contains either comma or whitespace besides the new line separator`, + ); + } } } - check_prefix_suffix("prefix", prefix); - check_prefix_suffix("suffix", suffix); + // prefix and suffix has different whitespace separators, we are deprecating + // prefix's separators besides new lines + check_prefix_suffix("prefix", suffix, true); + check_prefix_suffix("suffix", suffix, false); core.debug(JSON.stringify(github.context)); const allTags = await calculateTags({