Skip to content

Commit

Permalink
#1970 - Simplify labeling scheme to major, minor, patch (#1999)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreycarvalho authored Sep 20, 2024
1 parent 0c7d88d commit d3841fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
19 changes: 3 additions & 16 deletions .github/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@ changelog:
authors:
- dependabot
categories:
- title: Breaking Changes 🛠
- title: Major Changes
labels:
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- title: Bug Fixes 🐜
labels:
- bug
- hotfix
- title: Security Fixes 🔐
labels:
- security
- title: Internal Upgrades 📈
labels:
- internal
- title: Other Changes 🧑‍💻
- major
- title: Other Changes
labels:
- "*"
23 changes: 15 additions & 8 deletions .github/scripts/prData.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,35 @@ async function fetchReleaseBranchSha(github, owner, repo) {

/**
* Processes labels from pull requests to determine the new version and relevant labels for a release.
* EXPECTS ONLY ONE LABEL, as is currently our process for merging PRs
* @param {Array<Object>} labels - An array of label objects from pull requests.
* @param {string} currentVersion - The current release version.
* @returns {Object} - An object containing the new version and label.
*/
function processLabelsAndVersion(labels, currentVersion) {
// Split the current version into major, minor, and patch parts
let versionParts = currentVersion.split('.').map((x) => parseInt(x, 10));
let label = labels[0].name;

// Extract the label names from the labels array
const labelNames = labels.map(labelObj => labelObj.name);

let label; // To store the resulting label for the version bump

// Determine the type of version bump based on the label
if (label === 'breaking-change') {
// Determine the type of version bump based on the presence of labels
if (labelNames.includes('major')) {
// Major version bump
versionParts[0] += 1;
versionParts[1] = 0;
versionParts[2] = 0;
} else if (['hotfix', 'security', 'bug', 'internal'].includes(label)) {
// Patch version bump
versionParts[2] += 1;
} else {
label = 'major';
} else if (labelNames.includes('minor')) {
// Minor version bump
versionParts[1] += 1;
versionParts[2] = 0;
label = 'minor';
} else {
// Patch version bump (default)
versionParts[2] += 1;
label = 'patch';
}

// newVersion is in the format X.X.X
Expand All @@ -73,6 +79,7 @@ function processLabelsAndVersion(labels, currentVersion) {
};
}


/**
* Main function to handle pull request data for a GitHub repository.
* @param {Object} params - Parameters including GitHub client and context.
Expand Down
11 changes: 4 additions & 7 deletions .github/scripts/prLabelSemver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ function determineSemverValue(label) {
console.log('Received label:', label);

try {
if (label.includes('breaking change')) {
if (label.includes('major')) {
return 'MAJOR';
} else if (
label.includes('hotfix') ||
label.includes('security') ||
label.includes('internal') ||
label.includes('bug')
label.includes('minor')
) {
return 'PATCH';
} else {
return 'MINOR';
} else {
return 'PATCH';
}
} catch (error) {
console.error('Error determining semver value:', error);
Expand Down

0 comments on commit d3841fa

Please sign in to comment.