fix(release): ensure tags for version match stable variant before prerelease (#30047)
This commit is contained in:
parent
2413a4393c
commit
888957a010
@ -57,6 +57,36 @@ describe('nx release releaseTagPattern', () => {
|
|||||||
|
|
||||||
afterEach(() => cleanupProject());
|
afterEach(() => cleanupProject());
|
||||||
|
|
||||||
|
it('should prefer stable versions over prereleases', async () => {
|
||||||
|
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
|
||||||
|
nxJson.release = {
|
||||||
|
releaseTagPattern: 'v{version}',
|
||||||
|
version: {
|
||||||
|
conventionalCommits: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return nxJson;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tag the existing commit as a prerelease
|
||||||
|
await runCommandAsync(`git tag -a v1.0.0-beta.1 -m "v1.0.0-beta.1"`);
|
||||||
|
|
||||||
|
// Resolve that prerelease as the current version
|
||||||
|
expect(runCLI(`release version -d`)).toContain(
|
||||||
|
`Resolved the current version as 1.0.0-beta.1 from git tag "v1.0.0-beta.1"`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Make a new commit and tag it as a stable version
|
||||||
|
await runCommandAsync(`echo "Hello" > README.md`);
|
||||||
|
await runCommandAsync(`git add README.md`);
|
||||||
|
await runCommandAsync(`git commit -m "chore: update README.md"`);
|
||||||
|
await runCommandAsync(`git tag -a v1.0.0 -m "v1.0.0"`);
|
||||||
|
|
||||||
|
expect(runCLI(`release version -d`)).toContain(
|
||||||
|
`Resolved the current version as 1.0.0 from git tag "v1.0.0"`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe('releaseTagPatternCheckAllBranchesWhen', () => {
|
describe('releaseTagPatternCheckAllBranchesWhen', () => {
|
||||||
it('should check the current branch first, and then fall back to all branches by default/when not specified', async () => {
|
it('should check the current branch first, and then fall back to all branches by default/when not specified', async () => {
|
||||||
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
|
updateJson<NxJsonConfiguration>('nx.json', (nxJson) => {
|
||||||
|
|||||||
@ -85,7 +85,14 @@ export async function getLatestGitTagForPattern(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultGitArgs = ['tag', '--sort', '-v:refname'];
|
const defaultGitArgs = [
|
||||||
|
// Apply git config to take version suffixes into account when sorting, e.g. 1.0.0 is newer than 1.0.0-beta.1
|
||||||
|
'-c',
|
||||||
|
'versionsort.suffix=-',
|
||||||
|
'tag',
|
||||||
|
'--sort',
|
||||||
|
'-v:refname',
|
||||||
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let tags: string[];
|
let tags: string[];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user