3939 pnpm turbo run compile
4040 pnpm turbo run test
4141
42+ - name : Configure npm auth (stable)
43+ env :
44+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
45+ run : |
46+ npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
47+ npm config set registry https://registry.npmjs.org/
48+
49+ - name : Debug npm auth (stable)
50+ env :
51+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
52+ run : |
53+ echo "Registry: $(npm config get registry)"
54+ echo "NPM_TOKEN length: ${#NPM_TOKEN}"
55+ npm whoami || echo "npm whoami failed - checking token"
56+ test -n "$NODE_AUTH_TOKEN" || (echo "NODE_AUTH_TOKEN missing" && exit 1)
57+
4258 - name : Publish packages to npm
4359 id : changesets
4460 uses : changesets/action@v1
5066 createGithubReleases : true
5167 env :
5268 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
69+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
5470
5571 - name : Debug npm auth (stable)
5672 if : ${{ !(github.event_name == 'workflow_dispatch' && inputs.dry_run) && steps.changesets.outputs.published != 'true' }}
7894 for (const name of pkgs) {
7995 const v = versions[name];
8096 if (!v) continue;
81- const info = JSON.parse(execSync('npm view ' + name + '@' + v + ' version dist.tarball gitHead --json').toString());
82- const tags = JSON.parse(execSync('npm view ' + name + ' dist-tags --json').toString());
83- out[name] = { version: info.version, tarball: info.dist?.tarball, gitHead: info.gitHead, distTags: tags };
97+ try {
98+ const info = JSON.parse(execSync('npm view ' + name + '@' + v + ' version dist.tarball gitHead --json').toString());
99+ const tags = JSON.parse(execSync('npm view ' + name + ' dist-tags --json').toString());
100+ out[name] = { version: info.version, tarball: info.dist?.tarball, gitHead: info.gitHead, distTags: tags };
101+ } catch (err) {
102+ console.error('Failed to get npm info for', name, ':', err.message);
103+ out[name] = { error: err.message };
104+ }
84105 }
85106 process.stdout.write('info='+JSON.stringify(out));
86107 " >> $GITHUB_OUTPUT
@@ -97,9 +118,14 @@ jobs:
97118 for (const name of pkgs) {
98119 const expected = versions[name];
99120 if (!expected) continue;
100- const tags = JSON.parse(execSync('npm view ' + name + ' dist-tags --json').toString());
101- if (tags.latest !== expected) {
102- console.error(`[stable] Dist-tag mismatch for ${name}: latest=${tags.latest} expected=${expected}`);
121+ try {
122+ const tags = JSON.parse(execSync('npm view ' + name + ' dist-tags --json').toString());
123+ if (tags.latest !== expected) {
124+ console.error(`[stable] Dist-tag mismatch for ${name}: latest=${tags.latest} expected=${expected}`);
125+ process.exit(1);
126+ }
127+ } catch (err) {
128+ console.error('Failed to verify dist-tags for', name, ':', err.message);
103129 process.exit(1);
104130 }
105131 }
@@ -185,4 +211,35 @@ jobs:
185211 log_url: `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`,
186212 environment_url: envUrl,
187213 description: desc
188- })
214+ });
215+
216+ - name : Create deployment (stable - failed publish)
217+ if : ${{ !(github.event_name == 'workflow_dispatch' && inputs.dry_run) && steps.changesets.outputs.published != 'true' }}
218+ uses : actions/github-script@v7
219+ env :
220+ VERSIONS : ${{ steps.versions.outputs.versions }}
221+ with :
222+ script : |
223+ const { owner, repo } = context.repo;
224+ const payload = {
225+ channel: 'stable',
226+ distTag: 'latest',
227+ versions: JSON.parse(process.env.VERSIONS || '{}'),
228+ error: 'npm publish failed'
229+ };
230+ const ref = context.sha;
231+ const dep = await github.rest.repos.createDeployment({
232+ owner, repo, ref,
233+ environment: 'stable',
234+ auto_merge: false,
235+ required_contexts: [],
236+ transient_environment: false,
237+ description: `npm publish failed`,
238+ payload: JSON.stringify(payload)
239+ });
240+ await github.rest.repos.createDeploymentStatus({
241+ owner, repo, deployment_id: dep.data.id,
242+ state: 'failure',
243+ log_url: `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}`,
244+ description: 'npm publish failed - check workflow logs'
245+ });
0 commit comments