deno.land / std@0.224.0 / _tools / release / 01_bump_version.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run=git,deno --no-check// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { getReleasesMdFile, loadRepo, VersionFile } from "./repo.ts";
const repo = await loadRepo();const versionFile = new VersionFile();const currentVersion = versionFile.version;const newVersion = versionFile.version.inc(getVersionIncrementKind());
// update version.tsconsole.log(`Bumping version from ${currentVersion} to ${newVersion}...`);versionFile.updateVersion(newVersion);
// update Releases.mdconst releasesMdFile = getReleasesMdFile();const versionGitLog = await getGitLogFromLastVersion();releasesMdFile.updateWithGitLog({ gitLog: versionGitLog, version: newVersion.toString(),});
// run deno fmtawait repo.runCommandWithOutput(["deno", "fmt", "Releases.md"]);
function getVersionIncrementKind() { if (Deno.args.some((a) => a === "--patch")) { return "patch"; } else if (Deno.args.some((a) => a === "--minor")) { return "minor"; } else if (Deno.args.some((a) => a === "--major")) { return "major"; } else { throw new Error("Please provide a --patch, --minor, or --major flag."); }}
async function getGitLogFromLastVersion() { // fetch the upstream tags and history await repo.gitFetchTags("upstream"); await repo.gitFetchHistory("upstream");
// get the git log from the current commit to the last version return await repo.getGitLogFromTags( "upstream", currentVersion.toString(), undefined, );}
Version Info