Skip to content

Commit c8e964d

Browse files
committed
refactor: add hotfix mode to release package
1 parent c6620ab commit c8e964d

File tree

4 files changed

+73
-27
lines changed

4 files changed

+73
-27
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
"release-be": "monkeytype-release --be",
4040
"release-no-deploy": "monkeytype-release --no-deploy",
4141
"release-dry": "monkeytype-release --dry",
42-
"hotfix-fe": "npm run build-fe && cd frontend && npm run deploy-live && monkeytype-purge",
43-
"hotfix-be": "monkeytype-deploy-be",
44-
"hotfix": "npm run hotfix-be && npm run hotfix-fe",
42+
"hotfix": "monkeytype-release --hotfix",
43+
"hotfix-fe": "monkeytype-release --hotfix --fe",
44+
"hotfix-be": "monkeytype-release --hotfix --be",
45+
"hotfix-dry": "monkeytype-release --hotfix --dry",
4546
"pretty-check": "prettier --check .",
4647
"pretty-check-be": "prettier --check ./backend",
4748
"pretty-check-fe": "prettier --check ./frontend/src",

packages/release/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"dev": "nodemon --watch src --exec \"node ./src/index.js --dry\"",
7+
"dev-hotfix": "nodemon --watch src --exec \"node ./src/index.js --dry --hotfix\"",
78
"dev-changelog": "nodemon ./src/buildChangelog.js",
89
"oxlint": "oxlint .",
910
"lint": "npm run oxlint",
@@ -16,9 +17,7 @@
1617
"oxlint": "0.16.7"
1718
},
1819
"bin": {
19-
"monkeytype-release": "./src/index.js",
20-
"monkeytype-purge": "./bin/purgeCfCache.sh",
21-
"monkeytype-deploy-be": "./bin/deployBackend.sh"
20+
"monkeytype-release": "./src/index.js"
2221
},
2322
"dependencies": {
2423
"@octokit/rest": "21.1.1",

packages/release/src/index.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const noDeploy = args.has("--no-deploy");
1717
const isBackend = args.has("--be");
1818
const isDryRun = args.has("--dry");
1919
const noSyncCheck = args.has("--no-sync-check");
20+
const hotfix = args.has("--hotfix");
2021

2122
const PROJECT_ROOT = path.resolve(__dirname, "../../../");
2223

@@ -235,27 +236,31 @@ const createGithubRelease = async (version, changelogContent) => {
235236
};
236237

237238
const main = async () => {
238-
console.log("Starting release process...");
239+
console.log(`Starting ${hotfix ? "hotfix" : "release"} process...`);
239240

240-
checkBranchSync();
241+
if (!hotfix) checkBranchSync();
241242

242243
checkUncommittedChanges();
243244

244-
const changelogContent = await generateChangelog();
245+
let changelogContent;
246+
let newVersion;
247+
if (!hotfix) {
248+
changelogContent = await generateChangelog();
245249

246-
console.log(changelogContent);
250+
console.log(changelogContent);
247251

248-
if (!readlineSync.keyInYN("Changelog looks good?")) {
249-
console.log("Exiting.");
250-
process.exit(1);
251-
}
252-
253-
const currentVersion = getCurrentVersion();
254-
const newVersion = incrementVersion(currentVersion);
252+
if (!readlineSync.keyInYN("Changelog looks good?")) {
253+
console.log("Exiting.");
254+
process.exit(1);
255+
}
255256

257+
const currentVersion = getCurrentVersion();
258+
newVersion = incrementVersion(currentVersion);
259+
console.log(`New version: ${newVersion}`);
260+
}
256261
buildProject();
257262

258-
if (!readlineSync.keyInYN(`Ready to release ${newVersion}?`)) {
263+
if (!hotfix && !readlineSync.keyInYN(`Ready to release ${newVersion}?`)) {
259264
console.log("Exiting.");
260265
process.exit(1);
261266
}
@@ -269,16 +274,22 @@ const main = async () => {
269274
}
270275

271276
if (!noDeploy) purgeCache();
272-
updatePackage(newVersion);
273-
createCommitAndTag(newVersion);
274-
try {
275-
await createGithubRelease(newVersion, changelogContent);
276-
} catch (e) {
277-
console.error(`Failed to create release on GitHub: ${e}`);
278-
console.log("Please create the release manually.");
277+
if (!hotfix) {
278+
updatePackage(newVersion);
279+
createCommitAndTag(newVersion);
280+
try {
281+
await createGithubRelease(newVersion, changelogContent);
282+
} catch (e) {
283+
console.error(`Failed to create release on GitHub: ${e}`);
284+
console.log("Please create the release manually.");
285+
}
279286
}
280287

281-
console.log(`Release ${newVersion} completed successfully.`);
288+
if (hotfix) {
289+
console.log("Hotfix completed successfully.");
290+
} else {
291+
console.log(`Release ${newVersion} completed successfully.`);
292+
}
282293
process.exit(0);
283294
};
284295

pnpm-lock.yaml

Lines changed: 36 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)