Skip to content

Commit

Permalink
chore: 🔨 Improve release script
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Oct 29, 2024
1 parent 6475cae commit 8aa0a61
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (status.stdout.length !== 0) {
Deno.exit(1);
}

info("Running tests");
info("> Running tests");

if (
!new Deno.Command("deno", {
Expand All @@ -32,6 +32,43 @@ if (
Deno.exit(1);
}

info("Tests passed");
info("> Type-checking");
if (
!new Deno.Command("deno", {
args: ["check", "**/*.ts"],
stdout: "inherit",
"stderr": "inherit",
}).outputSync().success
) {
critical("Type-checking failed");
Deno.exit(1);
}
info("Type-checking passed");
info("> Linting");
if (
!new Deno.Command("deno", {
args: ["lint"],
stdout: "inherit",
"stderr": "inherit",
}).outputSync().success
) {
critical("Linting failed");
Deno.exit(1);
}
info("Linting passed");
info("> Linting Documentation");
if (
!new Deno.Command("deno", {
args: ["doc", "--lint", "**/*.ts"],
stdout: "inherit",
"stderr": "inherit",
}).outputSync().success
) {
critical("Linting Documentation failed");
Deno.exit(1);
}

const CURRENT_FILE = import.meta.url.replace("file://", "");
Deno.chdir(resolve(CURRENT_FILE, "..", ".."));

Expand All @@ -52,7 +89,7 @@ const newVersion = format(increment(parse(currentVersion), bump.releaseType));

info(`Bumping version from ${currentVersion} to ${newVersion}`);

info("Updating deno.json");
info("> Updating deno.json");

Deno.writeTextFile(
"./deno.json",
Expand All @@ -67,7 +104,7 @@ Deno.writeTextFile(
);

info("Updated deno.json");
info("Generating changelog");
info("> Generating changelog");

const changelog = await new Promise<string>((resolve, reject) => {
let data = "#";
Expand All @@ -93,6 +130,7 @@ const newChangelog = oldChangelog.replace(
Deno.writeTextFile("./CHANGELOG.md", newChangelog);

info("Updated CHANGELOG.md");
info("> Adding files to git");
if (
!new Deno.Command("git", {
args: ["add", "deno.json", "CHANGELOG.md"],
Expand All @@ -106,6 +144,7 @@ if (

info("Added files to git");

info("> Committing changes");
if (
!new Deno.Command("git", {
args: ["commit", "-m", `chore(release): Release v${newVersion} 🚀`],
Expand All @@ -118,10 +157,17 @@ if (
}

info("Committed changes");
info("> Tagging release");

if (
!new Deno.Command("git", {
args: ["tag", `v${newVersion}`],
args: [
"tag",
"-a",
`v${newVersion}`,
"-m",
changelog.split("\n").slice(1).join("\n"),
],
stdout: "inherit",
"stderr": "inherit",
}).outputSync().success
Expand All @@ -131,3 +177,5 @@ if (
}

info("Tagged release");
info("Release complete 🚀");
info("Run `git push --follow-tags` to push changes to the remote repository");

0 comments on commit 8aa0a61

Please sign in to comment.