Skip to content

Commit 2201864

Browse files
authored
✨ feat: add rc release config (#661)
* ✨ feat: support rc prerelease * ✅ test: fix test * 📸 test: update snapshot * 🐛 fix: try to fix release tag problem * 📝 docs: add config document
1 parent 226573a commit 2201864

File tree

11 files changed

+243
-117
lines changed

11 files changed

+243
-117
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- master
66
- beta
7+
- rc-*
78

89
jobs:
910
test:

.prettierrc.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
const config = require('@umijs/max/prettier');
22

3-
module.exports = { ...config, printWidth: 100 };
3+
module.exports = {
4+
...config,
5+
printWidth: 100,
6+
overrides: [
7+
{
8+
files: '*.md',
9+
options: {
10+
parser: 'markdown',
11+
proseWrap: 'preserve',
12+
},
13+
},
14+
],
15+
};

jest.config.base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const base: Config.InitialOptions = createConfig({
66
target: 'node',
77
});
88

9+
delete base.testTimeout;
10+
911
const config: Config.InitialOptions = {
1012
...base,
1113
moduleNameMapper: {
@@ -15,6 +17,7 @@ const config: Config.InitialOptions = {
1517
'@gitmoji/commit-types': '<rootDir>/packages/commit-types/src',
1618
},
1719
rootDir: path.resolve(__dirname, '.'),
20+
coveragePathIgnorePatterns: ['/node_modules/', '/lib/', '/es/'],
1821
};
1922

2023
export default config;

packages/release-config/CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# Changelog
22

3+
# semantic-release-config-gitmoji [1.4.0-rc.3](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-02)
4+
5+
# semantic-release-config-gitmoji [1.4.0-rc.2](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-02)
6+
7+
# semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-02)
8+
9+
### ✨ Features
10+
11+
- add rc release config ([17403dd](https://github.com/arvinxx/gitmoji-commit-workflow/commit/17403dd))
12+
- support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3))
13+
14+
### 🐛 Bug Fixes
15+
16+
- try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a))
17+
18+
# semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-02)
19+
20+
### ✨ Features
21+
22+
- support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3))
23+
24+
### 🐛 Bug Fixes
25+
26+
- try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a))
27+
28+
# semantic-release-config-gitmoji [1.4.0-rc.1](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-02)
29+
30+
### ✨ Features
31+
32+
- support rc prerelease ([2457ab3](https://github.com/arvinxx/gitmoji-commit-workflow/commit/2457ab3))
33+
34+
### 🐛 Bug Fixes
35+
36+
- try to fix release tag problem ([6da470a](https://github.com/arvinxx/gitmoji-commit-workflow/commit/6da470a))
37+
338
# semantic-release-config-gitmoji [1.3.0](https://github.com/arvinxx/gitmoji-commit-workflow/compare/semantic-release-config-gitmoji@[email protected]) (2023-01-01)
439

540
### ✨ Features

packages/release-config/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,60 @@ module.exports = {
1717

1818
### Create your config
1919

20+
use this in monorepo
21+
2022
```js
23+
// .releaserc.js
2124
const { createConfig } = require('semantic-release-config-gitmoji/lib/createConfig');
2225

2326
const config = createConfig({ monorepo: true });
2427

2528
module.exports = config;
2629
```
2730

31+
## createConfig params
32+
33+
### Common Options
34+
35+
| name | type | optional | default | description |
36+
| -------------- | --------------- | -------- | -------------- | ----------- |
37+
| releaseRules | `ReleaseRule[]` | `true` | `n/a` | |
38+
| changelogTitle | `string` | `true` | `# Changelog` | |
39+
| changelogFile | `string` | `true` | `CHANGELOG.md` | |
40+
41+
### Git Params
42+
43+
| name | type | optional | default | description |
44+
| --------- | -------- | ---------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
45+
| message | `string` | `true` | `:bookmark: chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}` | The message for the release commit. See [message](#message). |
46+
| gitAssets | `false` | `string[]` | `['CHANGELOG.md', 'package.json']` | Files to include in the release commit.Set to `false` to disable adding files to the release commit. See [assets](#assets). |
47+
48+
### Github Params
49+
50+
| name | type | optional | default | description |
51+
| ------------ | --------- | -------- | ------- | ---------------- |
52+
| enableGithub | `boolean` | `true` | `true` | 开启 github 插件 |
53+
54+
### NPM Params
55+
56+
| name | type | optional | default | description |
57+
| ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
58+
| enableNPM | `boolean` | `true` | `true` | 开启 npm 插件 |
59+
| npmPublish | `boolean` | `true` | `n/a` | Whether to publish the `npm` package to the registry. If `false` the `package.json` version will still be updated. `false` if the `package.json` [private](https://docs.npmjs.com/files/package.json#private) property is `true`, `true` otherwise |
60+
| pkgRoot | `string` | `true` | `n/a` | Directory path to publish. default: `.` |
61+
| tarballDir | `string` | `false` | `true` | `n/a` |
62+
| monorepo | `boolean` | `true` | `n/a` | 如果是 Monorepo 仓库发布 npm 包,使用 "@semrel-extra/npm" 替代官方包 if using monorepo, use "@semrel-extra/npm" instead of the official package |
63+
64+
# GithubPluginOpts
65+
66+
| name | type | optional | default | description |
67+
| ------------------- | ---------- | -------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68+
| githubUrl | `string` | `true` | `GH_URL` or `GITHUB_URL` environment variable. | The GitHub Enterprise endpoint. |
69+
| githubApiPathPrefix | `string` | `true` | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. | The GitHub Enterprise API prefix. |
70+
| githubAssets | `string[]` | `true` | `-` | An array of files to upload to the release. See [assets](#assets). |
71+
| proxy | `string` | `true` | `HTTP_PROXY` environment variable. | The proxy to use to access the GitHub API. See [proxy](#proxy). |
72+
| successComment | `string` | `true` | :tada: This issue has been resolved in version ${nextRelease.version} :tada: | The release is available on [GitHub release](github_release_url) The [assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users) to add to the issue created when a release fails. |
73+
2874
## License
2975

3076
[MIT](../../LICENSE) ® Arvin Xu

packages/release-config/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "semantic-release-config-gitmoji",
3-
"version": "1.3.0",
3+
"version": "1.4.0-rc.3",
44
"description": "a gitmoji commit style presets for semantic-release",
55
"keywords": [
66
"conventional-changelog",
@@ -30,7 +30,9 @@
3030
"clean": "rm -rf es lib dist build coverage src/.umi* .eslintcache",
3131
"cov": "jest --coverage",
3232
"start": "father dev",
33-
"test": "jest"
33+
"test": "jest",
34+
"test:cov": "jest --coverage",
35+
"test:update": "jest -u"
3436
},
3537
"dependencies": {
3638
"@gitmoji/commit-types": "1.1.5",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`get default config 1`] = `
4+
{
5+
"branches": [
6+
"master",
7+
{
8+
"channel": "rc",
9+
"name": "rc-*",
10+
"prerelease": "rc",
11+
},
12+
{
13+
"name": "rc",
14+
"prerelease": true,
15+
},
16+
"alpha",
17+
"beta",
18+
],
19+
"plugins": [
20+
[
21+
"@semantic-release/commit-analyzer",
22+
{
23+
"config": "conventional-changelog-gitmoji-config",
24+
"releaseRules": [
25+
{
26+
"release": "patch",
27+
"type": "style",
28+
},
29+
{
30+
"release": "patch",
31+
"type": "build",
32+
},
33+
],
34+
},
35+
],
36+
[
37+
"@semantic-release/release-notes-generator",
38+
{
39+
"config": "conventional-changelog-gitmoji-config",
40+
},
41+
],
42+
[
43+
"@semantic-release/changelog",
44+
{
45+
"changelogFile": "CHANGELOG.md",
46+
"changelogTitle": "# Changelog",
47+
},
48+
],
49+
"@semantic-release/npm",
50+
"@semantic-release/github",
51+
[
52+
"@semantic-release/git",
53+
{
54+
"assets": [
55+
"CHANGELOG.md",
56+
"package.json",
57+
],
58+
"message": ":bookmark: chore(release): \${nextRelease.gitTag} [skip ci]
59+
60+
\${nextRelease.notes}",
61+
},
62+
],
63+
],
64+
}
65+
`;

packages/release-config/src/createConfig.test.ts

Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,78 @@ import createConfig from './createConfig';
22

33
describe('createConfig', () => {
44
it('disable npm plugin', () => {
5-
expect(createConfig({ enableNPM: false })).toEqual({
6-
plugins: [
7-
[
8-
'@semantic-release/commit-analyzer',
9-
{
10-
config: 'conventional-changelog-gitmoji-config',
11-
releaseRules: [
12-
{ type: 'style', release: 'patch' },
13-
{ type: 'build', release: 'patch' },
14-
],
15-
},
16-
],
17-
[
18-
'@semantic-release/release-notes-generator',
19-
{
20-
config: 'conventional-changelog-gitmoji-config',
21-
},
22-
],
23-
[
24-
'@semantic-release/changelog',
25-
{
26-
changelogFile: 'CHANGELOG.md',
27-
changelogTitle: '# Changelog',
28-
},
29-
],
30-
'@semantic-release/github',
31-
[
32-
'@semantic-release/git',
33-
{
34-
assets: ['CHANGELOG.md', 'package.json'],
35-
message:
36-
// eslint-disable-next-line no-template-curly-in-string
37-
':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}',
38-
},
39-
],
5+
expect(createConfig({ enableNPM: false }).plugins).toEqual([
6+
[
7+
'@semantic-release/commit-analyzer',
8+
{
9+
config: 'conventional-changelog-gitmoji-config',
10+
releaseRules: [
11+
{ type: 'style', release: 'patch' },
12+
{ type: 'build', release: 'patch' },
13+
],
14+
},
4015
],
41-
});
16+
[
17+
'@semantic-release/release-notes-generator',
18+
{
19+
config: 'conventional-changelog-gitmoji-config',
20+
},
21+
],
22+
[
23+
'@semantic-release/changelog',
24+
{
25+
changelogFile: 'CHANGELOG.md',
26+
changelogTitle: '# Changelog',
27+
},
28+
],
29+
'@semantic-release/github',
30+
[
31+
'@semantic-release/git',
32+
{
33+
assets: ['CHANGELOG.md', 'package.json'],
34+
message:
35+
// eslint-disable-next-line no-template-curly-in-string
36+
':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}',
37+
},
38+
],
39+
]);
4240
});
4341

4442
it('disable github plugin', () => {
45-
expect(createConfig({ enableGithub: false })).toEqual({
46-
plugins: [
47-
[
48-
'@semantic-release/commit-analyzer',
49-
{
50-
config: 'conventional-changelog-gitmoji-config',
51-
releaseRules: [
52-
{ type: 'style', release: 'patch' },
53-
{ type: 'build', release: 'patch' },
54-
],
55-
},
56-
],
57-
[
58-
'@semantic-release/release-notes-generator',
59-
{
60-
config: 'conventional-changelog-gitmoji-config',
61-
},
62-
],
63-
[
64-
'@semantic-release/changelog',
65-
{
66-
changelogFile: 'CHANGELOG.md',
67-
changelogTitle: '# Changelog',
68-
},
69-
],
70-
'@semantic-release/npm',
71-
[
72-
'@semantic-release/git',
73-
{
74-
assets: ['CHANGELOG.md', 'package.json'],
75-
message:
76-
// eslint-disable-next-line no-template-curly-in-string
77-
':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}',
78-
},
79-
],
43+
expect(createConfig({ enableGithub: false }).plugins).toEqual([
44+
[
45+
'@semantic-release/commit-analyzer',
46+
{
47+
config: 'conventional-changelog-gitmoji-config',
48+
releaseRules: [
49+
{ type: 'style', release: 'patch' },
50+
{ type: 'build', release: 'patch' },
51+
],
52+
},
53+
],
54+
[
55+
'@semantic-release/release-notes-generator',
56+
{
57+
config: 'conventional-changelog-gitmoji-config',
58+
},
59+
],
60+
[
61+
'@semantic-release/changelog',
62+
{
63+
changelogFile: 'CHANGELOG.md',
64+
changelogTitle: '# Changelog',
65+
},
66+
],
67+
'@semantic-release/npm',
68+
[
69+
'@semantic-release/git',
70+
{
71+
assets: ['CHANGELOG.md', 'package.json'],
72+
message:
73+
// eslint-disable-next-line no-template-curly-in-string
74+
':bookmark: chore(release): ${nextRelease.gitTag} [skip ci] \n\n${nextRelease.notes}',
75+
},
8076
],
81-
});
77+
]);
8278
});
8379
});

packages/release-config/src/createConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export const createConfig = (options?: Options): SemRelOptions => {
7474

7575
return {
7676
plugins: plugins.filter((p) => !!p),
77+
branches: [
78+
'master',
79+
{ name: 'rc-*', prerelease: 'rc', channel: 'rc' },
80+
{ name: 'rc', prerelease: true },
81+
'alpha',
82+
'beta',
83+
],
7784
};
7885
};
7986

0 commit comments

Comments
 (0)