Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,4 @@ jobs:
if: needs.context.outputs.trigger == 'release'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm --filter=publish exec tsx src/ci/bin.ts gh-release --version ${{ needs.context.outputs.version }}
run: pnpm --filter=publish exec tsx src/ci/bin.ts gh-release --version ${{ needs.context.outputs.version }} --latest ${{ needs.context.outputs.latest }}
9 changes: 6 additions & 3 deletions scripts/publish/src/ci/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,13 @@ program
.command("gh-release")
.description("Create or update GitHub release")
.option("--version <version>", "Version (defaults to resolved context)")
.option("--latest <bool>", "Mark the release as GitHub's latest (defaults to resolved context)")
.action(async (opts) => {
const version =
opts.version ?? (await resolveContext()).version;
await createGhRelease(version);
const ctx = await resolveContext();
const version: string = opts.version ?? ctx.version;
const latest =
opts.latest !== undefined ? opts.latest === "true" : ctx.latest;
await createGhRelease(version, latest);
});

// ---------------------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions scripts/publish/src/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ export async function tagAndPush(version: string): Promise<void> {
* Create (or update) a GitHub release for the version. If a release with the
* same name already exists, its tag is updated to match. New releases with a
* prerelease identifier (anything containing `-`) are marked as prerelease.
*
* `latest` is passed to GitHub explicitly because `gh release create` marks
* every new stable release as the repository's latest release by default, so a
* release from a maintenance line such as `2.x` would otherwise take it over.
*/
export async function createGhRelease(version: string): Promise<void> {
export async function createGhRelease(
version: string,
latest: boolean,
): Promise<void> {
log.info(`creating GitHub release for ${version}`);

const { stdout: currentTag } = await $`git describe --tags --exact-match`;
Expand All @@ -55,7 +62,7 @@ export async function createGhRelease(version: string): Promise<void> {
log.info(`creating new release ${version} -> tag ${tagName}`);
await $({
stdio: "inherit",
})`gh release create ${tagName} --title ${version} --generate-notes`;
})`gh release create ${tagName} --title ${version} --generate-notes --latest=${latest ? "true" : "false"}`;

// Prerelease detection: anything with a `-` is a prerelease per semver.
if (version.includes("-")) {
Expand Down
Loading