mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
chore: updated release assist
* chore(deps): use commit-and-tag-version as standard-version is now deprecated, switch to maintained fork * chore: separate changelog and release npm scripts * chore: skip tags for commit-and-tag-version * docs: update release docs to reflect changes * chore: change npm scripts names * chore: try out IOWait * chore: use postrelease to finalize * build: update package-lock * docs: update release docs * docs: fix indent and prerelease instruction * chore: chronological changelog order * chore: release finalizer tweaks * docs: tweak release docs * chore: straightforward version import
This commit is contained in:
62
scripts/finalizeRelease.ts
Normal file
62
scripts/finalizeRelease.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env ts-node
|
||||
/* eslint-disable no-console */
|
||||
import * as readline from 'readline';
|
||||
import simpleGit from 'simple-git';
|
||||
import { version } from '../package.json';
|
||||
|
||||
/**
|
||||
* Script: upgradeConfigs.ts
|
||||
* Run with: ts-node scripts/upgradeConfig.ts
|
||||
* ------------------------------------------
|
||||
* Amend the previous commit with changes to the changelog
|
||||
* Then tag and push it. This script is run after
|
||||
* `npx commit-and-tag-version`
|
||||
*/
|
||||
|
||||
/**
|
||||
* Amends the previous commit, creates the annotated release tag
|
||||
* and then pushes commit and tag.
|
||||
*/
|
||||
async function commitAndTag(): Promise<void> {
|
||||
await simpleGit().commit([], 'CHANGELOG.md', { '--amend': null, '--no-edit': null, '--no-verify': null });
|
||||
await simpleGit().addAnnotatedTag(`v${version}`, `Release Version ${version}`);
|
||||
await simpleGit().push({ '--follow-tags': null });
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user for input
|
||||
* @param query - A string to prompt the user
|
||||
* @returns Promise with the input of the user
|
||||
*/
|
||||
async function waitForUserInput(query: string): Promise<string> {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
});
|
||||
return new Promise((resolve): void => rl.question(query, (answer): void => {
|
||||
rl.close();
|
||||
resolve(answer);
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Halts the script, waiting for user input before
|
||||
* committing the changelog changes, adding an
|
||||
* annotated tag and pushing the changes to origin.
|
||||
*/
|
||||
async function finalizeRelease(): Promise<void> {
|
||||
await waitForUserInput('Manually edit CHANGELOG.md, press any key to finalize...');
|
||||
return commitAndTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the process and writes out an error in case something goes wrong.
|
||||
*/
|
||||
function endProcess(error: Error): never {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
finalizeRelease()
|
||||
.then((): void => console.info(`Changes and tag v${version} pushed to origin.`))
|
||||
.catch(endProcess);
|
||||
@@ -2,5 +2,8 @@
|
||||
"extends": "../tsconfig.json",
|
||||
"include": [
|
||||
"."
|
||||
]
|
||||
],
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user