Skip to content

Commit 26a5c9f

Browse files
authored
ci: fix oidc publishing (#441)
## Summary `yarn npm publish` does not support oidc. ## How did you test this change? <!-- Frontend - Leave a screencast or a screenshot to visually describe the changes. --> ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the release publishing path from `yarn publish` to per-workspace `npm publish`, which can impact automated releases if workspace filtering, tags, or error handling behave differently. > > **Overview** > Switches the publish script from `yarn publish` to `npm publish` so releases can use npm's native OIDC authentication (including `--provenance`). > > The script now enumerates publishable `@launchdarkly/*` workspaces (excluding internal packages and examples), applies an optional `prerelease` dist-tag, and tolerates "already published" errors to support partial retry runs. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit bdb6629. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2ddd651 commit 26a5c9f

1 file changed

Lines changed: 41 additions & 8 deletions

File tree

scripts/publish-npm.sh

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
11
#!/bin/bash -ex
2+
3+
# Publishes @launchdarkly/* npm packages using the npm CLI.
4+
# Uses npm's native OIDC support for authentication (requires npm >= 11.5.1).
5+
26
if $LD_RELEASE_IS_DRYRUN ; then
37
echo "Doing a dry run of publishing."
4-
else
5-
if $LD_RELEASE_IS_PRERELEASE ; then
6-
echo "Publishing with prerelease tag."
7-
yarn publish --tag prerelease || { echo "npm publish failed" >&2; exit 1; }
8-
else
9-
yarn publish || { echo "npm publish failed" >&2; exit 1; }
10-
fi
11-
fi
8+
exit 0
9+
fi
10+
11+
# Get the list of publishable @launchdarkly workspaces from yarn,
12+
# excluding the root workspace and internal-only packages.
13+
WORKSPACES=$(yarn workspaces list --json | \
14+
node -e "
15+
const lines = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n');
16+
const exclude = new Set(['@launchdarkly/observability-sdk', '@launchdarkly/observability-shared']);
17+
for (const line of lines) {
18+
const {name, location} = JSON.parse(line);
19+
if (name.startsWith('@launchdarkly/') && !exclude.has(name) && !location.includes('/example')) {
20+
console.log(location);
21+
}
22+
}
23+
")
24+
25+
TAG_ARGS=""
26+
if $LD_RELEASE_IS_PRERELEASE ; then
27+
echo "Publishing with prerelease tag."
28+
TAG_ARGS="--tag prerelease"
29+
fi
30+
31+
for workspace in $WORKSPACES; do
32+
echo "Publishing $workspace..."
33+
# npm returns 403 when a version is already published. Tolerate this to allow
34+
# partial retries (matching the old yarn --tolerate-republish behavior).
35+
OUTPUT=$(npm publish "./$workspace" --access public --provenance $TAG_ARGS 2>&1) || {
36+
if echo "$OUTPUT" | grep -q "You cannot publish over the previously published versions"; then
37+
echo "Already published $workspace, skipping."
38+
else
39+
echo "$OUTPUT" >&2
40+
echo "npm publish failed for $workspace" >&2
41+
exit 1
42+
fi
43+
}
44+
done

0 commit comments

Comments
 (0)