Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions actions/release-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,25 @@ runs:
return newVersion;
}

// validate tag is a plain semver (not a monorepo service-prefixed tag like "sast/8.11.3")
if (!/^v?\d+\.\d+\.\d+$/.test(tagName)) {
console.log(`latest release tag "${tagName}" is not a plain semver tag, treating as no release`);
console.log(`next version: ${newVersion}`);
return newVersion;
}

console.log('latestPublishedTime', latestRelease.data.published_at)
const latestPublishedTime = new Date(latestRelease.data.published_at);

// extract major, minor and patch numbers from the latest release tag
const [major, minor, patch] = tagName.replace(/^v/, "").split(".").map((x) => parseInt(x));

if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
console.log(`Failed to parse version from tag "${tagName}", treating as no release`);
console.log(`next version: ${newVersion}`);
return newVersion;
}

console.log('latestTag', tagName)

// get all pull requests merged since the latest tag was created
Expand Down Expand Up @@ -81,6 +94,10 @@ runs:
? `${major}.${minor}.${patch + 1}`
: undefined;

if (newVersion && !/^\d+\.\d+\.\d+$/.test(newVersion)) {
throw new Error(`Computed invalid version "${newVersion}" - aborting to prevent corrupt release`);
}

if (newVersion) {
console.log(`next version: ${newVersion}`);
} else {
Expand Down
17 changes: 17 additions & 0 deletions actions/release-version/release-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@ module.exports = async (github, context) => {
return newVersion;
}

// validate tag is a plain semver (not a monorepo service-prefixed tag like "sast/8.11.3")
if (!/^v?\d+\.\d+\.\d+$/.test(tagName)) {
console.log(`latest release tag "${tagName}" is not a plain semver tag, treating as no release`);
console.log(`next version: ${newVersion}`);
return newVersion;
}

console.log('latestPublishedTime', latestRelease.data.published_at)
const latestPublishedTime = new Date(latestRelease.data.published_at);

// extract major, minor and patch numbers from the latest release tag
const [major, minor, patch] = tagName.replace(/^v/, "").split(".").map((x) => parseInt(x));

if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
console.log(`Failed to parse version from tag "${tagName}", treating as no release`);
console.log(`next version: ${newVersion}`);
return newVersion;
}

console.log('latestTag', tagName)

// get all pull requests merged since the latest tag was created
Expand Down Expand Up @@ -55,6 +68,10 @@ module.exports = async (github, context) => {
? `${major}.${minor}.${patch + 1}`
: undefined;

if (newVersion && !/^\d+\.\d+\.\d+$/.test(newVersion)) {
throw new Error(`Computed invalid version "${newVersion}" - aborting to prevent corrupt release`);
}

if (newVersion) {
console.log(`next version: ${newVersion}`);
} else {
Expand Down
Loading