From b54716d110f7ec32922f5fb65249cb797d0f5fee 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 | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/bumpversion.ts b/bumpversion.ts index 62d7107..f686194 100755 --- a/bumpversion.ts +++ b/bumpversion.ts @@ -7,10 +7,11 @@ 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"] }); + convco (["version", "--bump", "HEAD"] ); interface DenoJson extends Record { version: string; @@ -29,13 +30,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("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); + } }