Skip to content

Commit

Permalink
fix: tags with -dev suffix generate incompatible nightly version keep…
Browse files Browse the repository at this point in the history
…ing stability at alpha (#108)
  • Loading branch information
Vinai authored Sep 11, 2023
1 parent 851729a commit 2c6d96e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/release-branch-build-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ async function getPackagesForBuildInstruction(instructions) {
let toBeBuilt = {};

const {repoUrl} = instructions;


// use the latest tag in branch ref
const baseVersionsOnRef = await getLatestTag(repoUrl);
console.log(`Basing ${repoUrl} package versions on those from tag ${baseVersionsOnRef}`);
Expand All @@ -34,7 +34,7 @@ async function getPackagesForBuildInstruction(instructions) {
toBeBuilt = await determinePackagesForRef(repoUrl, dir, baseVersionsOnRef, {excludes});
Object.assign(packages, toBeBuilt);
}

for (const individualPackage of (instructions.packageIndividual || [])) {
const defaults = {excludes: [], composerJsonPath: '', emptyDirsToAdd: []};
const {label, dir, excludes, composerJsonPath, emptyDirsToAdd} = Object.assign(defaults, individualPackage);
Expand All @@ -61,7 +61,7 @@ async function getPackagesForBuildInstruction(instructions) {
toBeBuilt = await determineMagentoCommunityEditionProject(repoUrl, baseVersionsOnRef);
Object.assign(packages, toBeBuilt);
}

repo.clearCache();
return packages;
}
Expand All @@ -83,9 +83,7 @@ async function getPackageVersionsForBuildInstructions(buildInstructions, suffix)
function addSuffixToVersion(version, buildSuffix) {
const pos = version.indexOf('-');
if (pos !== -1) {
const suffix = version.slice(pos)
// dev is special. composer/semver parser throws an exception if the buildSuffix is appended without a '+'
return `${version.slice(0, pos)}${suffix === '-dev' ? '-dev+' : suffix}${buildSuffix}`
return `${version.slice(0, pos)}${(version.slice(pos))}${buildSuffix}`
}
return `${version}-a${buildSuffix || 'lpha'}`
}
Expand Down Expand Up @@ -113,8 +111,10 @@ function calcNightlyBuildPackageBaseVersion(version) {
} else {
parts[parts.length - 1]++;
}

return `${parts.join('.')}${suffix}`;

// The -dev suffix is special.
// The composer/semver parser throws an exception, so we prepend the buildSuffix with -alpha if it is dev to alpha-dev
return `${parts.join('.')}${suffix === '-dev' ? '-alpha-dev' : suffix}`;
}

/**
Expand Down Expand Up @@ -189,4 +189,4 @@ module.exports = {
transformVersionsToNightlyBuildVersions,
calcNightlyBuildPackageBaseVersion,
getReleaseDateString,
};
};
4 changes: 2 additions & 2 deletions tests/release-branch-build-tools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('It calculates the version', () => {
expect(sut.calcNightlyBuildPackageBaseVersion('103.0.2.1')).toBe('103.0.2.2');
expect(sut.calcNightlyBuildPackageBaseVersion('v103.0.2.1')).toBe('v103.0.2.2');
expect(sut.calcNightlyBuildPackageBaseVersion('0.4.0-beta1')).toBe('0.4.0.1-beta1');
expect(sut.calcNightlyBuildPackageBaseVersion('1.2.0-dev')).toBe('1.2.0.1-dev');
expect(sut.calcNightlyBuildPackageBaseVersion('1.2.0-dev')).toBe('1.2.0.1-alpha-dev');
});


Expand All @@ -27,7 +27,7 @@ test('It updates every version in the input package->version map', () => {
expect(sut.transformVersionsToNightlyBuildVersions({
'foo/bar': '1.2.0-dev'
}, '20220703')).toEqual({
'foo/bar': '1.2.0.1-dev+20220703'
'foo/bar': '1.2.0.1-alpha-dev20220703'
})
expect(sut.transformVersionsToNightlyBuildVersions({
'foo/bar': '1.2.0-beta1'
Expand Down

0 comments on commit 2c6d96e

Please sign in to comment.