Skip to content

Commit adcd050

Browse files
authored
Prepare release v2.0.0-beta.1 (#487)
* Add changelog script for beta * Prepare release v2.0.0-beta.1
1 parent a1df6ed commit adcd050

File tree

7 files changed

+141
-7
lines changed

7 files changed

+141
-7
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.0.0-beta.1 (Mar 10, 2023)
2+
3+
High level enhancements
4+
5+
- Added sass loader to theme webpack config
6+
7+
Other enhancements and bug fixes
8+
9+
- Checkout v2.0.0 instead of main ([#486](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/486))
10+
- Add sass loader to theme webpack config ([#484](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/484))
11+
- Add canary support to v2 ([#485](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/485))
12+
113
## 2.0.0-beta.0 (Mar 9, 2023)
214

315
High level enhancements

demo/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "demo",
3-
"version": "2.0.0-beta.0",
3+
"version": "2.0.0-beta.1",
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
@@ -27,8 +27,8 @@
2727
"@docusaurus/preset-classic": "^2.3.0",
2828
"@mdx-js/react": "^1.6.22",
2929
"clsx": "^1.1.1",
30-
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.0",
31-
"docusaurus-theme-openapi-docs": "^2.0.0-beta.0",
30+
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.1",
31+
"docusaurus-theme-openapi-docs": "^2.0.0-beta.1",
3232
"prism-react-renderer": "^1.3.1",
3333
"react": "^17.0.2",
3434
"react-dom": "^17.0.2"

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0-beta.0",
2+
"version": "2.0.0-beta.1",
33
"npmClient": "yarn",
44
"useWorkspaces": true
55
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"test:cypress:dev": "start-server-and-test watch:demo http://localhost:3000 cy:open",
3535
"test:cypress": "start-server-and-test serve http://localhost:3000 cy:run",
3636
"release:changelog": "scripts/changelog.ts",
37+
"release:changelogBeta": "scripts/changelog-beta.ts",
3738
"release:version": "scripts/version.ts",
3839
"release:publish": "scripts/publish.ts",
3940
"clean": "yarn workspace demo clean-all && rm -rf node_modules build demo/.docusaurus demo/build demo/node_modules && find packages -name node_modules -type d -maxdepth 2 -exec rm -rf {} + && find packages -name dist -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib -type d -maxdepth 2 -exec rm -rf {} + && find packages -name lib-next -type d -maxdepth 2 -exec rm -rf {} +"

packages/docusaurus-plugin-openapi-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "docusaurus-plugin-openapi-docs",
33
"description": "OpenAPI plugin for Docusaurus.",
4-
"version": "2.0.0-beta.0",
4+
"version": "2.0.0-beta.1",
55
"license": "MIT",
66
"keywords": [
77
"openapi",

packages/docusaurus-theme-openapi-docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "docusaurus-theme-openapi-docs",
33
"description": "OpenAPI theme for Docusaurus.",
4-
"version": "2.0.0-beta.0",
4+
"version": "2.0.0-beta.1",
55
"license": "MIT",
66
"keywords": [
77
"openapi",
@@ -51,7 +51,7 @@
5151
"buffer": "^6.0.3",
5252
"clsx": "^1.1.1",
5353
"crypto-js": "^4.1.1",
54-
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.0",
54+
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.1",
5555
"docusaurus-plugin-sass": "^0.2.3",
5656
"file-saver": "^2.0.5",
5757
"immer": "^9.0.7",

scripts/changelog-beta.ts

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env ts-node
2+
/* ============================================================================
3+
* Copyright (c) Palo Alto Networks
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
* ========================================================================== */
8+
9+
import pkg from "../lerna.json";
10+
import { getOutput } from "./utils/get-output";
11+
import { printBanner, printSpacer } from "./utils/print-utils";
12+
13+
const ORG = "PaloAltoNetworks";
14+
const REPO = "docusaurus-openapi-docs";
15+
const BRANCH = "v2.0.0";
16+
17+
const COMMIT_FILTERS = [/\(release\) v.*/];
18+
19+
// Makes the script crash on unhandled rejections instead of silently
20+
// ignoring them. In the future, promise rejections that are not handled will
21+
// terminate the Node.js process with a non-zero exit code.
22+
process.on("unhandledRejection", (err) => {
23+
throw err;
24+
});
25+
26+
function findUpstreamMaster() {
27+
const remotes = getOutput("git remote -v").split(/\r?\n/);
28+
29+
for (const remote of remotes) {
30+
const [name, url, method] = remote.split(/\s/);
31+
32+
const r = new RegExp(`${ORG}\\/${REPO}(\\.git)?$`);
33+
34+
if (r.test(url) && method === "(push)") {
35+
return `${name}/${BRANCH}`;
36+
}
37+
}
38+
return undefined;
39+
}
40+
41+
function findLatestTag() {
42+
return getOutput(`git describe --tags --abbrev=0 --match "v*"`);
43+
}
44+
45+
function getCommits(commitRange: string) {
46+
return getOutput(`git log --pretty="%s" ${commitRange}`).split(/\r?\n/);
47+
}
48+
49+
function formatCommits(commits: string[]) {
50+
return commits
51+
.filter((c) => {
52+
for (const filter of COMMIT_FILTERS) {
53+
if (filter.test(c)) {
54+
return false;
55+
}
56+
}
57+
return true;
58+
})
59+
.map((c) => {
60+
const r = /\(#(\d+)\)$/;
61+
return `- ${c.replace(
62+
r,
63+
`([#$1](https://github.com/${ORG}/${REPO}/pull/$1))`
64+
)}`;
65+
});
66+
}
67+
68+
function main() {
69+
const args = process.argv.slice(2);
70+
let commitRange;
71+
if (args.length > 0) {
72+
commitRange = args.join(" ");
73+
} else {
74+
const latestTag = findLatestTag();
75+
if (latestTag === undefined) {
76+
console.error("Error: Unable to find the latest tag.");
77+
process.exit(1);
78+
}
79+
80+
const upstream = findUpstreamMaster();
81+
if (upstream === undefined) {
82+
console.error("Error: Unable to find the upstream.");
83+
process.exit(1);
84+
}
85+
commitRange = `${latestTag}...${upstream}`;
86+
}
87+
88+
console.log(`Comparing ${commitRange}`);
89+
90+
const commits = getCommits(commitRange);
91+
const formattedCommits = formatCommits(commits);
92+
93+
if (formattedCommits.length === 0) {
94+
console.error("Error: There has been no changes since last release.");
95+
process.exit(1);
96+
}
97+
98+
const date = new Date().toLocaleDateString("en-US", {
99+
month: "short",
100+
day: "numeric",
101+
year: "numeric",
102+
});
103+
104+
const changelog = `
105+
## ${pkg.version} (${date})
106+
107+
High level enhancements
108+
109+
- TODO HIGHLIGHTS
110+
111+
Other enhancements and bug fixes
112+
113+
${formattedCommits.join("\n")}
114+
`;
115+
116+
printBanner("Prepend the following to CHANGELOG.md");
117+
console.log(changelog);
118+
printSpacer();
119+
}
120+
121+
main();

0 commit comments

Comments
 (0)