Skip to content

Commit e0ef881

Browse files
committed
chore(dev-utils): Update release script to hopefully work with prereleases
1 parent 5376be1 commit e0ef881

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

changelog.config.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ const { tokens, packages } = require('./changelogData');
66
const PACKAGE_REGEXP = new RegExp(`${packages.join('|')}`);
77

88
const GROUPS = [
9+
'Breaking Changes',
910
'Bug Fixes',
1011
'Features',
1112
'Documentation',
1213
'Performance Improvements',
1314
'Other Internal Changes',
1415
];
16+
const BREAKING_CHANGES = 'Breaking Changes';
1517

18+
/**
19+
* @param commit {import("conventional-commits-parser").Commit}
20+
*/
1621
function getCommitType({ type, scope, revert }) {
1722
if (type === 'revert' || revert) {
1823
return 'Reverts';
@@ -74,6 +79,9 @@ function tokenize(subject) {
7479
.replace(/([a-z][A-z]+Props)/g, '`$1`');
7580
}
7681

82+
/**
83+
* @type {import("conventional-changelog-core").ParserOptions}
84+
*/
7785
const parserOpts = {
7886
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
7987
headerCorrespondence: ['type', 'scope', 'subject'],
@@ -83,6 +91,9 @@ const parserOpts = {
8391
revertCorrespondence: ['header', 'hash'],
8492
};
8593

94+
/**
95+
* @type {import("conventional-changelog-core").WriterOptions}
96+
*/
8697
const writerOpts = {
8798
transform: (commit, context) => {
8899
// don't want to show the release tag in changelog
@@ -93,8 +104,8 @@ const writerOpts = {
93104
const issues = [];
94105
let isBreaking = false;
95106
commit.notes.forEach((note) => {
96-
isBreaking = false;
97-
note.title = 'BREAKING CHANGES';
107+
isBreaking = true;
108+
note.title = BREAKING_CHANGES;
98109
});
99110

100111
commit.type = getCommitType(commit);
@@ -165,6 +176,8 @@ const writerOpts = {
165176
* This is basically the conventional-changelog-angular with a few changes to
166177
* allow more commit messages to appear. I also "tokenize" known packages and
167178
* exports from react-md in the changelogs.
179+
*
180+
* @type {import("conventional-changelog-core").Options.Config}
168181
*/
169182
module.exports = {
170183
parserOpts,

packages/dev-utils/src/release.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export async function release({
7979
clean: enableClean,
8080
type,
8181
}: Options): Promise<void> {
82+
const prerelease = type.startsWith("pre");
8283
const localDotEnv = join(projectRoot, ".env.local");
8384
dotenv.config({ path: localDotEnv });
8485
const { GITHUB_TOKEN } = process.env;
@@ -141,14 +142,19 @@ A token can be created at:
141142
await replaceTag();
142143

143144
let distTag = "";
144-
if (type.startsWith("pre")) {
145+
if (prerelease) {
145146
distTag = " --dist-tag next";
146147
}
147148

148149
run(`npx lerna publish from-package${distTag}${yes}`);
149150
await continueOrRollback(autoYes);
150151

151-
git("push origin main");
152+
if (!prerelease) {
153+
git("push origin main");
154+
} else {
155+
// assuming I already have a branch for the prelease
156+
git("push");
157+
}
152158
git("push --tags");
153159

154160
log.info("Creating github release");
@@ -169,7 +175,7 @@ ${percentChanged}
169175
repo: "react-md",
170176
tag_name: `v${version}`,
171177
body,
172-
prerelease: type.startsWith("pre"),
178+
prerelease,
173179
}
174180
);
175181

0 commit comments

Comments
 (0)