From c0ffee76bc878a61e7a08623cc8504db5e5c0f99 Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Tue, 24 Dec 2024 15:01:12 +0100 Subject: [PATCH] chore: complete bump script --- bumpversion.ts | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/bumpversion.ts b/bumpversion.ts index 62d7107..2553b14 100755 --- a/bumpversion.ts +++ b/bumpversion.ts @@ -7,10 +7,10 @@ const run = (...args: ConstructorParameters) => 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 { version: string; @@ -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"'); + } }