Skip to content

Commit

Permalink
Prepare release v2.0.0-beta.1 (#487)
Browse files Browse the repository at this point in the history
* Add changelog script for beta

* Prepare release v2.0.0-beta.1
  • Loading branch information
sserrata authored Mar 10, 2023
1 parent a1df6ed commit adcd050
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 7 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 2.0.0-beta.1 (Mar 10, 2023)

High level enhancements

- Added sass loader to theme webpack config

Other enhancements and bug fixes

- Checkout v2.0.0 instead of main ([#486](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/486))
- Add sass loader to theme webpack config ([#484](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/484))
- Add canary support to v2 ([#485](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/485))

## 2.0.0-beta.0 (Mar 9, 2023)

High level enhancements
Expand Down
6 changes: 3 additions & 3 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand All @@ -27,8 +27,8 @@
"@docusaurus/preset-classic": "^2.3.0",
"@mdx-js/react": "^1.6.22",
"clsx": "^1.1.1",
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.0",
"docusaurus-theme-openapi-docs": "^2.0.0-beta.0",
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.1",
"docusaurus-theme-openapi-docs": "^2.0.0-beta.1",
"prism-react-renderer": "^1.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"npmClient": "yarn",
"useWorkspaces": true
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"test:cypress:dev": "start-server-and-test watch:demo http://localhost:3000 cy:open",
"test:cypress": "start-server-and-test serve http://localhost:3000 cy:run",
"release:changelog": "scripts/changelog.ts",
"release:changelogBeta": "scripts/changelog-beta.ts",
"release:version": "scripts/version.ts",
"release:publish": "scripts/publish.ts",
"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 {} +"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-openapi-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-plugin-openapi-docs",
"description": "OpenAPI plugin for Docusaurus.",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"license": "MIT",
"keywords": [
"openapi",
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-openapi-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-theme-openapi-docs",
"description": "OpenAPI theme for Docusaurus.",
"version": "2.0.0-beta.0",
"version": "2.0.0-beta.1",
"license": "MIT",
"keywords": [
"openapi",
Expand Down Expand Up @@ -51,7 +51,7 @@
"buffer": "^6.0.3",
"clsx": "^1.1.1",
"crypto-js": "^4.1.1",
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.0",
"docusaurus-plugin-openapi-docs": "^2.0.0-beta.1",
"docusaurus-plugin-sass": "^0.2.3",
"file-saver": "^2.0.5",
"immer": "^9.0.7",
Expand Down
121 changes: 121 additions & 0 deletions scripts/changelog-beta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env ts-node
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import pkg from "../lerna.json";
import { getOutput } from "./utils/get-output";
import { printBanner, printSpacer } from "./utils/print-utils";

const ORG = "PaloAltoNetworks";
const REPO = "docusaurus-openapi-docs";
const BRANCH = "v2.0.0";

const COMMIT_FILTERS = [/\(release\) v.*/];

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on("unhandledRejection", (err) => {
throw err;
});

function findUpstreamMaster() {
const remotes = getOutput("git remote -v").split(/\r?\n/);

for (const remote of remotes) {
const [name, url, method] = remote.split(/\s/);

const r = new RegExp(`${ORG}\\/${REPO}(\\.git)?$`);

if (r.test(url) && method === "(push)") {
return `${name}/${BRANCH}`;
}
}
return undefined;
}

function findLatestTag() {
return getOutput(`git describe --tags --abbrev=0 --match "v*"`);
}

function getCommits(commitRange: string) {
return getOutput(`git log --pretty="%s" ${commitRange}`).split(/\r?\n/);
}

function formatCommits(commits: string[]) {
return commits
.filter((c) => {
for (const filter of COMMIT_FILTERS) {
if (filter.test(c)) {
return false;
}
}
return true;
})
.map((c) => {
const r = /\(#(\d+)\)$/;
return `- ${c.replace(
r,
`([#$1](https://github.com/${ORG}/${REPO}/pull/$1))`
)}`;
});
}

function main() {
const args = process.argv.slice(2);
let commitRange;
if (args.length > 0) {
commitRange = args.join(" ");
} else {
const latestTag = findLatestTag();
if (latestTag === undefined) {
console.error("Error: Unable to find the latest tag.");
process.exit(1);
}

const upstream = findUpstreamMaster();
if (upstream === undefined) {
console.error("Error: Unable to find the upstream.");
process.exit(1);
}
commitRange = `${latestTag}...${upstream}`;
}

console.log(`Comparing ${commitRange}`);

const commits = getCommits(commitRange);
const formattedCommits = formatCommits(commits);

if (formattedCommits.length === 0) {
console.error("Error: There has been no changes since last release.");
process.exit(1);
}

const date = new Date().toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
});

const changelog = `
## ${pkg.version} (${date})
High level enhancements
- TODO HIGHLIGHTS
Other enhancements and bug fixes
${formattedCommits.join("\n")}
`;

printBanner("Prepend the following to CHANGELOG.md");
console.log(changelog);
printSpacer();
}

main();

0 comments on commit adcd050

Please sign in to comment.