Something went wrong. Try again.
A self-hosted household ledger.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889// Create (and optionally push) the ChronVer git tag for the current release.// The version is read from package.json; the tag is an annotated tag on the// commit that set it. Run this AFTER committing the release bump — pushing the// tag is what triggers the CI image build (.tangled/workflows/build-image.yml).//// deno task tag # create the annotated tag locally// deno task tag --push # also push it to origin (triggers CI)import { isChronVer, pkgVersion } from "./version.ts";import { lastReleaseCommit } from "./changelog.ts";
async function git(args: string[]) { const { code, stdout, stderr } = await new Deno.Command("git", { args, stdout: "piped", stderr: "piped", }).output(); return { code, out: new TextDecoder().decode(stdout).trim(), err: new TextDecoder().decode(stderr).trim(), };}
const version = await pkgVersion();if (!isChronVer(version)) { console.error( `package.json version "${version}" is not a ChronVer release — run \`deno task release\` first.`, ); Deno.exit(1);}
const commit = await lastReleaseCommit();if (!commit) { console.error( "No commit has set the version yet — commit the release bump first.", ); Deno.exit(1);}
// Guard: make sure the release bump is actually committed (not just in the// working copy), so the tag lands on the right commit.const shown = await git(["show", `${commit}:package.json`]);let committedVersion = "";try { committedVersion = JSON.parse(shown.out).version;} catch { /* ignore */ }if (committedVersion !== version) { console.error( `The bump to ${version} isn't committed yet (that commit's package.json is ${ committedVersion || "?" }). Commit the release, then re-run.`, ); Deno.exit(1);}
if ((await git(["tag", "--list", version])).out === version) { console.error(`Tag ${version} already exists.`); Deno.exit(1);}
const created = await git([ "tag", "-a", version, "-m", `release ${version}`, commit,]);if (created.code !== 0) { console.error(created.err); Deno.exit(1);}console.log(`Created tag ${version} at ${commit.slice(0, 12)}.`);
if (Deno.args.includes("--push")) { console.log("Pushing tag to origin (may prompt 1Password for SSH auth)..."); const pushed = await git(["push", "origin", version]); if (pushed.code !== 0) { console.error(pushed.err); Deno.exit(1); } console.log(pushed.err || pushed.out || "Pushed."); console.log("CI will build and publish the image for this tag.");} else { console.log( `Next: \`deno task tag --push\` (or \`git push origin ${version}\`) to trigger CI.`, );}