Skip to content

Commit caa2bca

Browse files
committed
fix: address release workflow review comments
1 parent 9665dd6 commit caa2bca

4 files changed

Lines changed: 53 additions & 5 deletions

File tree

.changeset/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The repo is currently in changesets **prerelease mode** with the `alpha` tag
2929
public npm channel for community testing is `preview`. While in this mode:
3030

3131
- `changeset version` cuts versions like `0.1.0-alpha.0`, `0.1.0-alpha.1`, …
32-
- `changeset publish --tag preview` publishes them under the **`preview`** npm dist-tag, **not** `latest`. So `npm install @zitadel/cli` keeps resolving the last stable release; consumers opt into preview bundles with `@zitadel/cli@preview`.
32+
- `scripts/publish-changesets.mjs` publishes them under the **`preview`** npm dist-tag, **not** `latest`, while `.changeset/pre.json` exists. So `npm install @zitadel/cli` keeps resolving the last stable release; consumers opt into preview bundles with `@zitadel/cli@preview`.
3333
- The public packages are configured as a fixed MVP preview group, so the Version Packages PR keeps their versions aligned.
3434

3535
To leave alpha and cut a stable `latest` release:
@@ -41,7 +41,7 @@ corepack pnpm changeset version # strips the -alpha suffix
4141

4242
## Publishing (npm trusted publishing / OIDC)
4343

44-
The [`.github/workflows/release-npm.yml`](../.github/workflows/release-npm.yml) workflow runs the [changesets GitHub Action](https://github.com/changesets/action). Pushing changesets to `main` opens a "Version Packages" PR aggregating all pending changesets; merging that PR bumps versions, updates `CHANGELOG.md` files, and publishes to npm (under the `preview` dist-tag while in prerelease mode). Package-level GitHub Releases are disabled; GoReleaser owns the product-level `ZITADEL Preview` releases. For the full product release order, follow the operator runbook in [`docs/operations/releasing.md`](../docs/operations/releasing.md).
44+
The [`.github/workflows/release-npm.yml`](../.github/workflows/release-npm.yml) workflow runs the [changesets GitHub Action](https://github.com/changesets/action). Pushing changesets to `main` opens a "Version Packages" PR aggregating all pending changesets; merging that PR bumps versions, updates `CHANGELOG.md` files, and publishes to npm. While `.changeset/pre.json` exists, the publish step uses the `preview` dist-tag; after `changeset pre exit`, it uses Changesets' default dist-tag (`latest`). Package-level GitHub Releases are disabled; GoReleaser owns the product-level `ZITADEL Preview` releases. For the full product release order, follow the operator runbook in [`docs/operations/releasing.md`](../docs/operations/releasing.md).
4545

4646
Publishing authenticates with **npm trusted publishing (OIDC)** — there is **no `NPM_TOKEN`** secret. Before the first automated publish, a maintainer must, once per public package:
4747

.github/workflows/release-npm.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ name: release-npm
1111
# dist-tag — `npm install @zitadel/cli` keeps resolving the last stable
1212
# `latest`; consumers opt into preview bundles with `@zitadel/cli@preview`. Run
1313
# `pnpm changeset pre exit` to leave alpha and cut a stable `latest` release.
14+
# The publish wrapper checks .changeset/pre.json: prereleases publish with
15+
# `--tag preview`; stable releases use Changesets' default dist-tag.
1416
#
1517
# Authentication uses npm trusted publishing (OIDC) — there is no NPM_TOKEN.
1618
# A maintainer must configure the trusted publisher for each public package
@@ -92,7 +94,7 @@ jobs:
9294
uses: changesets/action@v1
9395
with:
9496
version: corepack pnpm changeset version
95-
publish: corepack pnpm changeset publish --tag preview
97+
publish: node scripts/publish-changesets.mjs
9698
title: "chore: version packages"
9799
commit: "chore: version packages"
98100
createGithubReleases: false

scripts/delete-package-github-releases.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { spawnSync } from "node:child_process";
33

44
const execute = process.argv.includes("--execute");
5-
const limitIndex = process.argv.indexOf("--limit");
6-
const limit = limitIndex >= 0 ? process.argv[limitIndex + 1] : "200";
5+
const limit = readLimit(process.argv.slice(2));
76

87
const releases = JSON.parse(
98
run("gh", [
@@ -51,3 +50,25 @@ function run(command, args, options = {}) {
5150
}
5251
return result;
5352
}
53+
54+
function readLimit(args) {
55+
const limitIndex = args.indexOf("--limit");
56+
if (limitIndex < 0) {
57+
return "200";
58+
}
59+
60+
const value = args[limitIndex + 1];
61+
if (!value || value.startsWith("-") || !/^[1-9]\d*$/.test(value)) {
62+
usage(`--limit must be followed by a positive integer, got ${JSON.stringify(value)}`);
63+
}
64+
65+
return value;
66+
}
67+
68+
function usage(message) {
69+
console.error(message);
70+
console.error(
71+
"usage: node scripts/delete-package-github-releases.mjs [--execute] [--limit <positive-integer>]",
72+
);
73+
process.exit(1);
74+
}

scripts/publish-changesets.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
import { spawnSync } from "node:child_process";
3+
import { existsSync } from "node:fs";
4+
5+
const prereleaseMode = existsSync(".changeset/pre.json");
6+
const args = ["pnpm", "changeset", "publish"];
7+
if (prereleaseMode) {
8+
args.push("--tag", "preview");
9+
}
10+
11+
console.log(
12+
prereleaseMode
13+
? "Publishing changesets to npm with the preview dist-tag."
14+
: "Publishing changesets to npm with the default dist-tag.",
15+
);
16+
17+
const result = spawnSync("corepack", args, {
18+
stdio: "inherit",
19+
});
20+
21+
if (result.error) {
22+
throw new Error(`corepack ${args.join(" ")} failed: ${result.error.message}`);
23+
}
24+
25+
process.exit(result.status ?? 1);

0 commit comments

Comments
 (0)