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 c0ffee7
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 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,25 @@ 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 setVersion(next_version, denoData);
await run("deno", { args: ["fmt"] });

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.md");
await git("commit", "-m", '"chore: changelog"');
}
}

0 comments on commit c0ffee7

Please sign in to comment.