mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
Merge origin/main into simplify-ktx-releases
This commit is contained in:
commit
616fc211b0
9 changed files with 289 additions and 23 deletions
|
|
@ -146,12 +146,12 @@ export function publicNpmPackageJson(cliPackageJson, dependencies, version = PUB
|
|||
license: cliPackageJson.license ?? 'Apache-2.0',
|
||||
repository: {
|
||||
type: 'git',
|
||||
url: 'git+https://github.com/kaelio/ktx.git',
|
||||
url: 'https://github.com/Kaelio/ktx',
|
||||
},
|
||||
bugs: {
|
||||
url: 'https://github.com/kaelio/ktx/issues',
|
||||
url: 'https://github.com/Kaelio/ktx/issues',
|
||||
},
|
||||
homepage: 'https://github.com/kaelio/ktx#readme',
|
||||
homepage: 'https://github.com/Kaelio/ktx#readme',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,14 @@ describe('publicNpmPackageJson', () => {
|
|||
assert.deepEqual(packageJson.dependencies, { commander: '14.0.3' });
|
||||
assert.deepEqual(packageJson.bundledDependencies, PUBLIC_BUNDLED_WORKSPACE_PACKAGES);
|
||||
assert.deepEqual(packageJson.files, ['dist', 'assets']);
|
||||
assert.deepEqual(packageJson.repository, {
|
||||
type: 'git',
|
||||
url: 'https://github.com/Kaelio/ktx',
|
||||
});
|
||||
assert.deepEqual(packageJson.bugs, {
|
||||
url: 'https://github.com/Kaelio/ktx/issues',
|
||||
});
|
||||
assert.equal(packageJson.homepage, 'https://github.com/Kaelio/ktx#readme');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,26 @@ function releaseTag(kind) {
|
|||
return kind === 'rc' ? 'next' : 'latest';
|
||||
}
|
||||
|
||||
function releaseChangelogPlugins(kind) {
|
||||
return kind === 'rc' ? ['@semantic-release/changelog'] : [];
|
||||
}
|
||||
|
||||
function releaseGitPlugins(kind) {
|
||||
if (kind !== 'rc') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
[
|
||||
'@semantic-release/git',
|
||||
{
|
||||
assets: ['CHANGELOG.md', 'package.json', 'release-policy.json'],
|
||||
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
|
||||
},
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
function releaseBranches(env = process.env) {
|
||||
const branch = currentBranch(env);
|
||||
const kind = releaseKind(env);
|
||||
|
|
@ -137,7 +157,7 @@ function createReleaseConfig(env = process.env) {
|
|||
},
|
||||
},
|
||||
],
|
||||
'@semantic-release/changelog',
|
||||
...releaseChangelogPlugins(kind),
|
||||
[
|
||||
'@semantic-release/exec',
|
||||
{
|
||||
|
|
@ -161,13 +181,7 @@ function createReleaseConfig(env = process.env) {
|
|||
publishCmd: 'pnpm run release:published-smoke',
|
||||
},
|
||||
],
|
||||
[
|
||||
'@semantic-release/git',
|
||||
{
|
||||
assets: ['CHANGELOG.md', 'package.json', 'release-policy.json'],
|
||||
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
|
||||
},
|
||||
],
|
||||
...releaseGitPlugins(kind),
|
||||
[
|
||||
'@semantic-release/github',
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ function releaseExecOptions(config) {
|
|||
return config.plugins.find((plugin) => Array.isArray(plugin) && plugin[0] === '@semantic-release/exec' && plugin[1].prepareCmd)[1];
|
||||
}
|
||||
|
||||
function releaseExecIndex(config) {
|
||||
return config.plugins.findIndex((plugin) => Array.isArray(plugin) && plugin[0] === '@semantic-release/exec' && plugin[1].prepareCmd);
|
||||
}
|
||||
|
||||
function pluginNames(config) {
|
||||
return config.plugins.map((plugin) => (Array.isArray(plugin) ? plugin[0] : plugin));
|
||||
}
|
||||
|
||||
describe('semantic-release config', () => {
|
||||
it('configures rc releases on a dedicated next prerelease branch', () => {
|
||||
assert.equal(releaseKind({ KTX_RELEASE_KIND: 'rc' }), 'rc');
|
||||
|
|
@ -33,7 +41,15 @@ describe('semantic-release config', () => {
|
|||
releaseExecOptions(config).prepareCmd,
|
||||
/update-public-release-version\.mjs "\$\{nextRelease\.version\}" "next"/,
|
||||
);
|
||||
assert.doesNotMatch(releaseExecOptions(config).publishCmd ?? '', /release:npm-publish/);
|
||||
assert.doesNotMatch(JSON.stringify(config.plugins), /release:npm-publish/);
|
||||
const releaseFilePluginNames = pluginNames(config).filter(
|
||||
(plugin) => plugin === '@semantic-release/changelog' || plugin === '@semantic-release/git',
|
||||
);
|
||||
assert.deepEqual(releaseFilePluginNames, ['@semantic-release/changelog', '@semantic-release/git']);
|
||||
|
||||
const names = pluginNames(config);
|
||||
assert.ok(names.indexOf('@semantic-release/changelog') < releaseExecIndex(config));
|
||||
assert.ok(names.indexOf('@semantic-release/git') > releaseExecIndex(config));
|
||||
});
|
||||
|
||||
it('configures stable releases only from main with latest tag', () => {
|
||||
|
|
@ -49,6 +65,13 @@ describe('semantic-release config', () => {
|
|||
assert.equal(config.plugins.includes('./scripts/semantic-release-version-policy.cjs'), false);
|
||||
});
|
||||
|
||||
it('does not commit release files back to protected main during stable releases', () => {
|
||||
const config = createReleaseConfig({ KTX_RELEASE_KIND: 'stable', GITHUB_REF_NAME: 'main' });
|
||||
|
||||
assert.equal(pluginNames(config).includes('@semantic-release/git'), false);
|
||||
assert.equal(pluginNames(config).includes('@semantic-release/changelog'), false);
|
||||
});
|
||||
|
||||
it('rejects stable releases from non-main branches', () => {
|
||||
assert.throws(
|
||||
() => releaseBranches({ KTX_RELEASE_KIND: 'stable', GITHUB_REF_NAME: 'feature/release-test' }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue