Skip to content

Commit

Permalink
chore: complete bump script
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Dec 24, 2024
1 parent e2c9c7c commit c0ffee5
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions bumpversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const run = (...args: ConstructorParameters<typeof Deno.Command>) =>
new Deno.Command(...args).output()
.then((data: { stdout: BufferSource }) => dec(data.stdout));

const git = (args?: string[]) => run("git", { args });
const git = (...args: string[]) => run("git", { args });
const convco = (args?: string[]) => run("convco", { args });

const convcoNextVersion = () =>
run("convco", { args: ["version", "--bump", "HEAD"] });
const convcoNextVersion = () => convco(["version", "--bump", "HEAD"]);

interface DenoJson extends Record<string, unknown> {
version: string;
Expand All @@ -29,13 +29,24 @@ async function setVersion(newVersion: string, json: DenoJson) {

const denoData = await readDeno();

const current_branch = await git(["rev-parse", "--abbrev-ref", "HEAD"]);
const current_branch = await git("rev-parse", "--abbrev-ref", "HEAD");
const release_branch = "main";
const next_version = await convcoNextVersion();

if (current_branch != release_branch) {
console.error(`can only bump version on ${release_branch}`);
Deno.exit(1);
} else {
await setVersion(next_version, denoData);
if (import.meta.main) {
if (current_branch != release_branch) {
console.error(`can only bump version on ${release_branch}`);
Deno.exit(1);
} else {
const next_version = await convcoNextVersion();
await git("add", "deno.json", "deno.lock");
await git("commit", "-m", '"chore: bump version"');

await git("tag", `v${next_version}`);
await convco(["changelog", "-o", "CHANGELOG.md"]);

await git("add", "changelog");
await git("commit", "-m", '"chore: changelog"');

await setVersion(next_version, denoData);
}
}

0 comments on commit c0ffee5

Please sign in to comment.