Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .oxlintrc.effect.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"!packages/api/**",
"!packages/config/**",
"!packages/stack/**",
"!apps/cli/src/**",
"!apps/cli/tests/**",
"!apps/cli/vitest.config.ts",
"!apps/cli/**",
// Last match wins across the whole list: keep bare re-exclusions after every
// `!` entry that would otherwise re-include them.
"apps/cli/src/shared/cli/bin.ts",
Expand Down
55 changes: 39 additions & 16 deletions apps/cli/scripts/apply-release-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,56 @@
//
// Usage:
// bun apps/cli/scripts/apply-release-notes.ts --tag v2.101.0
import { BunFileSystem, BunPath } from "@effect/platform-bun";
import { $ } from "bun";
import { existsSync } from "node:fs";
import path from "node:path";
import { Console, Data, Effect, FileSystem, Layer, Path } from "effect";
import process from "node:process";
import { parseArgs } from "node:util";

class ShellCommandFailed extends Data.TaggedError("ShellCommandFailed")<{
readonly cause: unknown;
}> {}

const shell = <A>(command: () => Promise<A>) =>
Effect.tryPromise({ try: command, catch: (cause) => new ShellCommandFailed({ cause }) });

const { values } = parseArgs({
options: {
tag: { type: "string" },
},
strict: true,
});

const tag = values.tag;
if (!tag) {
console.error("--tag is required (e.g. --tag v2.101.0)");
process.exit(2);
}
const version = tag.replace(/^v/, "");
const main = Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;

const tag = values.tag;
if (!tag) {
yield* Console.error("--tag is required (e.g. --tag v2.101.0)");
return yield* Effect.sync(() => process.exit(2));
}
const version = tag.replace(/^v/, "");

const repoRoot = (yield* shell(() => $`git rev-parse --show-toplevel`.text())).trim();
const notesPath = path.join(repoRoot, "release-notes", `v${version}.md`);
if (!(yield* fs.exists(notesPath).pipe(Effect.orElseSucceed(() => false)))) {
yield* Console.error(`No notes file at ${path.relative(repoRoot, notesPath)}`);
return yield* Effect.sync(() => process.exit(1));
}

yield* Console.error(`==> Updating GitHub Release body for ${tag}`);
yield* shell(() => $`gh release edit ${tag} --notes-file ${notesPath}`.cwd(repoRoot));
yield* Console.error(`==> Done`);
});

const repoRoot = (await $`git rev-parse --show-toplevel`.text()).trim();
const notesPath = path.join(repoRoot, "release-notes", `v${version}.md`);
if (!existsSync(notesPath)) {
console.error(`No notes file at ${path.relative(repoRoot, notesPath)}`);
process.exit(1);
function thrownValue(error: { readonly message: string; readonly cause?: unknown }): unknown {
Comment thread
7ttp marked this conversation as resolved.
return error.cause !== undefined ? error.cause : new Error(error.message);
}

console.error(`==> Updating GitHub Release body for ${tag}`);
await $`gh release edit ${tag} --notes-file ${notesPath}`.cwd(repoRoot);
console.error(`==> Done`);
await Effect.runPromise(
main.pipe(
Effect.provide(Layer.mergeAll(BunFileSystem.layer, BunPath.layer)),
Effect.catch((error) => Effect.die(thrownValue(error))),
),
);
Loading
Loading