Skip to content

Commit

Permalink
chore(dev-utils): Update release script to hopefully work with prerel…
Browse files Browse the repository at this point in the history
…eases
  • Loading branch information
mlaursen committed Aug 13, 2021
1 parent 5376be1 commit e0ef881
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
17 changes: 15 additions & 2 deletions changelog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ const { tokens, packages } = require('./changelogData');
const PACKAGE_REGEXP = new RegExp(`${packages.join('|')}`);

const GROUPS = [
'Breaking Changes',
'Bug Fixes',
'Features',
'Documentation',
'Performance Improvements',
'Other Internal Changes',
];
const BREAKING_CHANGES = 'Breaking Changes';

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

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

/**
* @type {import("conventional-changelog-core").WriterOptions}
*/
const writerOpts = {
transform: (commit, context) => {
// don't want to show the release tag in changelog
Expand All @@ -93,8 +104,8 @@ const writerOpts = {
const issues = [];
let isBreaking = false;
commit.notes.forEach((note) => {
isBreaking = false;
note.title = 'BREAKING CHANGES';
isBreaking = true;
note.title = BREAKING_CHANGES;
});

commit.type = getCommitType(commit);
Expand Down Expand Up @@ -165,6 +176,8 @@ const writerOpts = {
* This is basically the conventional-changelog-angular with a few changes to
* allow more commit messages to appear. I also "tokenize" known packages and
* exports from react-md in the changelogs.
*
* @type {import("conventional-changelog-core").Options.Config}
*/
module.exports = {
parserOpts,
Expand Down
12 changes: 9 additions & 3 deletions packages/dev-utils/src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export async function release({
clean: enableClean,
type,
}: Options): Promise<void> {
const prerelease = type.startsWith("pre");
const localDotEnv = join(projectRoot, ".env.local");
dotenv.config({ path: localDotEnv });
const { GITHUB_TOKEN } = process.env;
Expand Down Expand Up @@ -141,14 +142,19 @@ A token can be created at:
await replaceTag();

let distTag = "";
if (type.startsWith("pre")) {
if (prerelease) {
distTag = " --dist-tag next";
}

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

git("push origin main");
if (!prerelease) {
git("push origin main");
} else {
// assuming I already have a branch for the prelease
git("push");
}
git("push --tags");

log.info("Creating github release");
Expand All @@ -169,7 +175,7 @@ ${percentChanged}
repo: "react-md",
tag_name: `v${version}`,
body,
prerelease: type.startsWith("pre"),
prerelease,
}
);

Expand Down

0 comments on commit e0ef881

Please sign in to comment.