require previous semver segment to be present for tagging, fix fully qualified semver not being tagged in additional to normalized ones, allow tag/branch tagging if != semver tag
This commit is contained in:
parent
47fb719517
commit
c2c9a6f265
58
dist/index.js
vendored
58
dist/index.js
vendored
@ -62189,7 +62189,6 @@ function writeRegistryAuthJson(registryAuthJson, targetFile) {
|
|||||||
console.log('debug_log_auth_json:', copy);
|
console.log('debug_log_auth_json:', copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('LEAK INTENTIONAL config json:', gBase64.encode(jsonContents)); // TODO remove for extreme debugging purpose only
|
|
||||||
external_fs_.writeFileSync(targetFile, jsonContents);
|
external_fs_.writeFileSync(targetFile, jsonContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62199,46 +62198,44 @@ function isNonEmptyStr(str) {
|
|||||||
|
|
||||||
function collectTags(information) {
|
function collectTags(information) {
|
||||||
const tags = [];
|
const tags = [];
|
||||||
let foundSemverTag = false;
|
let mostSpecificSemverTag = false;
|
||||||
let tagPrefix = (core.getInput('tag_prefix') ?? '').trim();
|
let tagPrefix = (core.getInput('tag_prefix') ?? '').trim();
|
||||||
let tagSuffix = (core.getInput('tag_suffix') ?? '').trim();
|
let tagSuffix = (core.getInput('tag_suffix') ?? '').trim();
|
||||||
let tagCommitPrefix = (core.getInput('tag_commit_prefix') ?? '').trim();
|
let tagCommitPrefix = (core.getInput('tag_commit_prefix') ?? '').trim();
|
||||||
|
|
||||||
// handle semver
|
|
||||||
console.log({
|
// tag semver
|
||||||
'tag_semver_enable' : core.getBooleanInput('tag_semver_enable'),
|
if (core.getBooleanInput('tag_semver_enable') && information.semver_valid) {
|
||||||
'tag_semver_major' : core.getBooleanInput('tag_semver_major'),
|
if (core.getBooleanInput('tag_semver_major') && information.semver_major != null) {
|
||||||
'tag_semver_minor' : core.getBooleanInput('tag_semver_minor'),
|
mostSpecificSemverTag = tagPrefix + information.semver_major;
|
||||||
'tag_semver_patch' : core.getBooleanInput('tag_semver_patch'),
|
tags.push(mostSpecificSemverTag);
|
||||||
'information.semver_major': information.semver_major,
|
|
||||||
'information.semver_minor': information.semver_minor,
|
if (core.getBooleanInput('tag_semver_minor') && information.semver_minor != null) {
|
||||||
'information.semver_patch': information.semver_patch,
|
mostSpecificSemverTag += '.' + information.semver_minor;
|
||||||
'information' : information
|
tags.push(mostSpecificSemverTag);
|
||||||
});
|
|
||||||
if (core.getBooleanInput('tag_semver_enable')) {
|
if (core.getBooleanInput('tag_semver_patch') && information.semver_patch != null) {
|
||||||
if (core.getBooleanInput('tag_semver_major') && isNonEmptyStr(information.semver_major)) {
|
mostSpecificSemverTag += '.' + information.semver_patch;
|
||||||
tags.push(tagPrefix + information.semver_major);
|
tags.push(mostSpecificSemverTag);
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
if (core.getBooleanInput('tag_semver_minor') && isNonEmptyStr(information.semver_minor)) {
|
|
||||||
tags.push(tagPrefix + information.semver_minor);
|
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
if (core.getBooleanInput('tag_semver_patch') && isNonEmptyStr(information.semver_patch)) {
|
|
||||||
tags.push(tagPrefix + information.semver_patch);
|
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle git tag/branch
|
// handle git tag/branch
|
||||||
if (core.getBooleanInput('tag_ref_normalized_enable') && foundSemverTag === false) {
|
if (core.getBooleanInput('tag_ref_normalized_enable')) {
|
||||||
|
// only apply tag IF it doesn't match the semver
|
||||||
if (isNonEmptyStr(information.git_tag)) {
|
if (isNonEmptyStr(information.git_tag)) {
|
||||||
// TODO normalize tag from git for docker
|
const normalizedTag = tagPrefix + normalizeGitRefForDockerTag(information.git_tag) + tagSuffix;
|
||||||
tags.push(tagPrefix + information.git_tag + tagSuffix);
|
if (mostSpecificSemverTag !== normalizedTag) {
|
||||||
|
tags.push(normalizedTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isNonEmptyStr(information.git_current_branch)) {
|
if (isNonEmptyStr(information.git_current_branch)) {
|
||||||
// TODO normalize branch from git for docker
|
const normalizedBranch = tagPrefix + normalizeGitRefForDockerTag(information.git_current_branch) + tagSuffix;
|
||||||
tags.push(tagPrefix + information.git_current_branch + tagSuffix);
|
if (mostSpecificSemverTag !== normalizedBranch) {
|
||||||
|
tags.push(normalizedBranch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62259,6 +62256,11 @@ function collectTags(information) {
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeGitRefForDockerTag(ref) {
|
||||||
|
return ref
|
||||||
|
.replaceAll('/', '-');
|
||||||
|
}
|
||||||
|
|
||||||
function prepareDestinations(registries, tags) {
|
function prepareDestinations(registries, tags) {
|
||||||
const destinations = [];
|
const destinations = [];
|
||||||
registries.forEach((registry) => {
|
registries.forEach((registry) => {
|
||||||
|
|||||||
57
src/lib.js
57
src/lib.js
@ -94,46 +94,44 @@ function isNonEmptyStr(str) {
|
|||||||
|
|
||||||
export function collectTags(information) {
|
export function collectTags(information) {
|
||||||
const tags = [];
|
const tags = [];
|
||||||
let foundSemverTag = false;
|
let mostSpecificSemverTag = false;
|
||||||
let tagPrefix = (core.getInput('tag_prefix') ?? '').trim();
|
let tagPrefix = (core.getInput('tag_prefix') ?? '').trim();
|
||||||
let tagSuffix = (core.getInput('tag_suffix') ?? '').trim();
|
let tagSuffix = (core.getInput('tag_suffix') ?? '').trim();
|
||||||
let tagCommitPrefix = (core.getInput('tag_commit_prefix') ?? '').trim();
|
let tagCommitPrefix = (core.getInput('tag_commit_prefix') ?? '').trim();
|
||||||
|
|
||||||
// handle semver
|
|
||||||
console.log({
|
// tag semver
|
||||||
'tag_semver_enable' : core.getBooleanInput('tag_semver_enable'),
|
if (core.getBooleanInput('tag_semver_enable') && information.semver_valid) {
|
||||||
'tag_semver_major' : core.getBooleanInput('tag_semver_major'),
|
if (core.getBooleanInput('tag_semver_major') && information.semver_major != null) {
|
||||||
'tag_semver_minor' : core.getBooleanInput('tag_semver_minor'),
|
mostSpecificSemverTag = tagPrefix + information.semver_major;
|
||||||
'tag_semver_patch' : core.getBooleanInput('tag_semver_patch'),
|
tags.push(mostSpecificSemverTag);
|
||||||
'information.semver_major': information.semver_major,
|
|
||||||
'information.semver_minor': information.semver_minor,
|
if (core.getBooleanInput('tag_semver_minor') && information.semver_minor != null) {
|
||||||
'information.semver_patch': information.semver_patch,
|
mostSpecificSemverTag += '.' + information.semver_minor;
|
||||||
'information' : information
|
tags.push(mostSpecificSemverTag);
|
||||||
});
|
|
||||||
if (core.getBooleanInput('tag_semver_enable')) {
|
if (core.getBooleanInput('tag_semver_patch') && information.semver_patch != null) {
|
||||||
if (core.getBooleanInput('tag_semver_major') && isNonEmptyStr(information.semver_major)) {
|
mostSpecificSemverTag += '.' + information.semver_patch;
|
||||||
tags.push(tagPrefix + information.semver_major);
|
tags.push(mostSpecificSemverTag);
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
if (core.getBooleanInput('tag_semver_minor') && isNonEmptyStr(information.semver_minor)) {
|
|
||||||
tags.push(tagPrefix + information.semver_minor);
|
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
if (core.getBooleanInput('tag_semver_patch') && isNonEmptyStr(information.semver_patch)) {
|
|
||||||
tags.push(tagPrefix + information.semver_patch);
|
|
||||||
foundSemverTag = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle git tag/branch
|
// handle git tag/branch
|
||||||
if (core.getBooleanInput('tag_ref_normalized_enable') && foundSemverTag === false) {
|
if (core.getBooleanInput('tag_ref_normalized_enable')) {
|
||||||
|
// only apply tag IF it doesn't match the semver
|
||||||
if (isNonEmptyStr(information.git_tag)) {
|
if (isNonEmptyStr(information.git_tag)) {
|
||||||
// TODO normalize tag from git for docker
|
const normalizedTag = tagPrefix + normalizeGitRefForDockerTag(information.git_tag) + tagSuffix;
|
||||||
tags.push(tagPrefix + information.git_tag + tagSuffix);
|
if (mostSpecificSemverTag !== normalizedTag) {
|
||||||
|
tags.push(normalizedTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isNonEmptyStr(information.git_current_branch)) {
|
if (isNonEmptyStr(information.git_current_branch)) {
|
||||||
// TODO normalize branch from git for docker
|
const normalizedBranch = tagPrefix + normalizeGitRefForDockerTag(information.git_current_branch) + tagSuffix;
|
||||||
tags.push(tagPrefix + information.git_current_branch + tagSuffix);
|
if (mostSpecificSemverTag !== normalizedBranch) {
|
||||||
|
tags.push(normalizedBranch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +152,11 @@ export function collectTags(information) {
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function normalizeGitRefForDockerTag(ref) {
|
||||||
|
return ref
|
||||||
|
.replaceAll('/', '-');
|
||||||
|
}
|
||||||
|
|
||||||
export function prepareDestinations(registries, tags) {
|
export function prepareDestinations(registries, tags) {
|
||||||
const destinations = [];
|
const destinations = [];
|
||||||
registries.forEach((registry) => {
|
registries.forEach((registry) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user