Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci(release): gate canaryOnly packages so lab publishes to @canary only (#3325)

Cindy Zhang8ac5550ec125
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e861a63a04..594e7af76a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -95,7 +95,10 @@ jobs:
published=0
for pkg_dir in packages/* packages/themes/*; do
[ -f "$pkg_dir/package.json" ] || continue
- IS_PUBLISHABLE=$(node -p "const p=require('./$pkg_dir/package.json'); !p.private && p.name?.startsWith('@astryxdesign/') ? 'yes' : 'no'")
+ # Stable `latest` never includes canaryOnly packages (e.g. lab):
+ # skip them explicitly so even an accidental `private: false` can
+ # never leak them onto the `latest` dist-tag.
+ IS_PUBLISHABLE=$(node -p "const p=require('./$pkg_dir/package.json'); !p.private && !p.astryx?.canaryOnly && p.name?.startsWith('@astryxdesign/') ? 'yes' : 'no'")
[ "$IS_PUBLISHABLE" = "yes" ] || continue
NAME=$(node -p "require('./$pkg_dir/package.json').name")
VERSION=$(node -p "require('./$pkg_dir/package.json').version")
@@ -159,12 +162,17 @@ jobs:
echo "Publishing canary ${CANARY_VERSION}"
- # Stamp canary version into all publishable packages
+ # Stamp canary version into all publishable packages. canaryOnly
+ # packages (e.g. lab) stay `private: true` in git as npm's hard
+ # guarantee against a stable publish; here — in the ephemeral CI
+ # checkout ONLY — we strip `private` so they publish to @canary.
for pkg in packages/*/package.json packages/themes/*/package.json; do
node -e "
const fs = require('fs');
const p = JSON.parse(fs.readFileSync('$pkg','utf8'));
- if (p.private || !p.name?.startsWith('@astryxdesign/')) process.exit(0);
+ if (!p.name?.startsWith('@astryxdesign/')) process.exit(0);
+ if (p.private && !p.astryx?.canaryOnly) process.exit(0);
+ if (p.private && p.astryx?.canaryOnly) delete p.private;
p.version = '${CANARY_VERSION}';
for (const dt of ['dependencies','peerDependencies','devDependencies']) {
if (!p[dt]) continue;
@@ -182,7 +190,9 @@ jobs:
# being silently swallowed.
for pkg_dir in packages/* packages/themes/*; do
[ -f "$pkg_dir/package.json" ] || continue
- IS_PUBLISHABLE=$(node -p "const p=require('./$pkg_dir/package.json'); !p.private && p.name?.startsWith('@astryxdesign/') ? 'yes' : 'no'")
+ # canaryOnly packages are publishable here (the stamp step above
+ # already stripped their `private` flag in this ephemeral checkout).
+ IS_PUBLISHABLE=$(node -p "const p=require('./$pkg_dir/package.json'); (!p.private || p.astryx?.canaryOnly) && p.name?.startsWith('@astryxdesign/') ? 'yes' : 'no'")
if [ "$IS_PUBLISHABLE" = "yes" ]; then
NAME=$(node -p "require('./$pkg_dir/package.json').name")
echo "Publishing ${NAME}@${CANARY_VERSION}"
diff --git a/scripts/npm/setup-trusted-publishing.mjs b/scripts/npm/setup-trusted-publishing.mjs
index b81ccc0299..9a060e3f14 100644
--- a/scripts/npm/setup-trusted-publishing.mjs
+++ b/scripts/npm/setup-trusted-publishing.mjs
@@ -105,6 +105,7 @@ function discoverPackages() {
dir,
name: p.name,
private: !!p.private,
+ canaryOnly: !!p.astryx?.canaryOnly,
version: p.version,
});
}
@@ -119,13 +120,17 @@ function readChangesetConfig() {
);
}
-// The 12 publishable @astryxdesign/* packages: non-private and not ignored.
-// Sorted by npm name for deterministic, readable output.
+// The publishable @astryxdesign/* packages that need a trusted-publisher config.
+// This includes canaryOnly packages (e.g. lab): they stay `private: true` in git
+// as npm's hard guard against a stable publish, but they DO publish to the
+// @canary dist-tag from CI, so their name must still be claimed (bootstrap) and
+// trusted here. Everything else is included when non-private; ignored packages
+// are always excluded. Sorted by npm name for deterministic, readable output.
function publishablePackages() {
const config = readChangesetConfig();
const ignore = new Set(config.ignore || []);
return discoverPackages()
- .filter(p => !p.private && !ignore.has(p.name))
+ .filter(p => (!p.private || p.canaryOnly) && !ignore.has(p.name))
.sort((a, b) => a.name.localeCompare(b.name));
}