Merge pull request #6 from every-app/263-release-notes-public-defaults

chore: default release notes to public main
This commit is contained in:
Ben Senescu 2026-03-16 22:05:09 -04:00 committed by GitHub
commit 0f3fa12d7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View File

@ -30,4 +30,5 @@ After reviewing the generated notes:
- tighten wording only when it improves clarity - tighten wording only when it improves clarity
- preserve the existing section structure unless there is a strong reason to merge sections - preserve the existing section structure unless there is a strong reason to merge sections
- suggest saving the finalized notes to `release-notes/v<version>.md` when a version is known - suggest saving the finalized notes to `release-notes/v<version>.md` when a version is known
- suggest the commands to update local `main` from the target remote before tagging, for example `git checkout main` and `git pull <remote> main`
- suggest a `gh release create` command if the user wants to publish next - suggest a `gh release create` command if the user wants to publish next

View File

@ -15,7 +15,7 @@ const { values } = parseArgs({
args: normalizedArgv, args: normalizedArgv,
options: { options: {
from: { type: "string" }, from: { type: "string" },
to: { type: "string", default: "HEAD" }, to: { type: "string" },
draft: { type: "string" }, draft: { type: "string" },
repo: { type: "string" }, repo: { type: "string" },
help: { type: "boolean", short: "h", default: false }, help: { type: "boolean", short: "h", default: false },
@ -25,7 +25,7 @@ const { values } = parseArgs({
if (values.help) { if (values.help) {
process.stdout.write( process.stdout.write(
`Usage: pnpm release:notes -- [options]\n\nOptions:\n --from <tag> Starting git tag. Defaults to latest semver tag.\n --to <ref> Ending git ref. Defaults to HEAD.\n --draft <tag> Create a draft GitHub release for the provided tag.\n --repo <owner/repo> Override GitHub repo slug for compare links and draft release.\n -h, --help Show this help message.\n`, `Usage: pnpm release:notes -- [options]\n\nOptions:\n --from <tag> Starting git tag. Defaults to latest semver tag.\n --to <ref> Ending git ref. Defaults to main for the public repo, otherwise HEAD.\n --draft <tag> Create a draft GitHub release for the provided tag.\n --repo <owner/repo> Override GitHub repo slug for compare links and draft release.\n -h, --help Show this help message.\n`,
); );
process.exit(0); process.exit(0);
} }
@ -43,6 +43,17 @@ function gh(args) {
}).trim(); }).trim();
} }
/** @param {string} remoteName */
function getRemoteRepo(remoteName) {
try {
const remote = git(["remote", "get-url", remoteName]);
const match = remote.match(/github\.com[:/]([^/]+\/[^/.]+)(?:\.git)?$/);
return match?.[1];
} catch {
return undefined;
}
}
function getLatestSemverTag() { function getLatestSemverTag() {
const tags = git(["tag", "--sort=-version:refname"]) const tags = git(["tag", "--sort=-version:refname"])
.split("\n") .split("\n")
@ -155,10 +166,13 @@ function getDefaultFromTag() {
return getLatestSemverTag(); return getLatestSemverTag();
} }
function getOriginRepo() { function getPreferredRepo() {
const remote = git(["remote", "get-url", "origin"]); return getRemoteRepo("public") ?? getRemoteRepo("origin");
const match = remote.match(/github\.com[:/]([^/]+\/[^/.]+)(?:\.git)?$/); }
return match?.[1];
/** @param {string | undefined} repo */
function getDefaultToRef(repo) {
return repo === "every-app/open-seo" ? "main" : "HEAD";
} }
/** @param {readonly string[]} rangeArgs */ /** @param {readonly string[]} rangeArgs */
@ -266,8 +280,8 @@ function buildNotes({ from, to, repo }) {
} }
const from = values.from ?? getDefaultFromTag(); const from = values.from ?? getDefaultFromTag();
const to = values.to; const repo = values.repo ?? getPreferredRepo();
const repo = values.repo ?? getOriginRepo(); const to = values.to ?? getDefaultToRef(repo);
const notes = buildNotes({ from, to, repo }); const notes = buildNotes({ from, to, repo });
process.stdout.write(`${notes}\n`); process.stdout.write(`${notes}\n`);