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
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ jobs:
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
# No registry-url: trusted publishing needs no token, and the
# placeholder `.npmrc` entry setup-node writes would make npm try
# token auth instead of the OIDC exchange.
package-manager-cache: false

# The runner image can resolve its own older node/npm ahead of the
Expand Down
6 changes: 4 additions & 2 deletions .llm/references/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ transfer to the `Ambiguous-Interactive` organization, the GitHub OIDC claims nam
package owner can change it: npmjs.com → the package → Settings → Trusted Publisher → GitHub Actions → Organization `Ambiguous-Interactive`, Repository `DxVisualizer`, Workflow
filename `release.yml`, Environment empty, allow `npm publish`.

The `publish-npm` action now explains a 404 this way instead of only echoing the registry text. Once the registration names the current repository, `operation=publish` with
`dry_run=false` finishes the release: npm publication, the GitHub Release, and the uploaded archives.
The `publish-npm` action now explains a 404 this way instead of only echoing the registry text, quotes npm's own debug log (which records the OIDC exchange the registry answered),
and publishes with `--loglevel=http`. Publication also runs without `setup-node`'s `registry-url`, because the placeholder `_authToken` that option writes makes npm attempt token
authentication instead of the OIDC exchange trusted publishing needs. Once the registration names the current repository, `operation=publish` with `dry_run=false` finishes the
release: npm publication, the GitHub Release, and the uploaded archives.

## Rerun and recovery

Expand Down
24 changes: 22 additions & 2 deletions scripts/release/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,13 @@ def publish_npm(self) -> None:
if self.run([npm, 'view', identity, 'version'], capture=True, check=False).returncode == 0:
emit(f'::notice::{identity} is already on the registry; skipping publish.')
return
published = self.run([npm, 'publish', self.value('PACKAGE_FILE'), '--access', 'public', '--tag', self.value('NPM_TAG')], capture=True, check=False)
# Trusted publishing needs no token, and the HTTP level output names
# the OIDC exchange the registry answered, which a bare E404 hides.
published = self.run([npm, 'publish', self.value('PACKAGE_FILE'), '--access', 'public', '--tag', self.value('NPM_TAG'),
'--loglevel=http'], capture=True, check=False)
if published.returncode:
detail = (published.stderr or published.stdout or '').strip()
raise ValueError(f'npm publish of {identity} failed ({published.returncode}): {detail}{self.registry_hint(detail)}')
raise ValueError(f'npm publish of {identity} failed ({published.returncode}): {detail}{self.registry_hint(detail)}{self.npm_debug_report()}')
emit(f"::notice::Published {identity} to dist-tag '{self.value('NPM_TAG')}'.")

def registry_hint(self, detail: str) -> str:
Expand All @@ -325,6 +328,23 @@ def registry_hint(self, detail: str) -> str:
return ('\nThe registry answered 404, which npm also uses when the package Trusted Publisher does not name this repository and workflow. '
f'Confirm the npm Trusted Publisher for this package lists {repository} and .github/workflows/release.yml.')

def npm_debug_report(self, directory: Optional[Path] = None) -> str:
"""Quote npm's own debug log, which carries the registry's reason."""
log_directory = directory if directory is not None else Path.home() / '.npm' / '_logs'
try:
# npm names debug logs with an ISO timestamp, so name order is
# chronological and stable where file timestamps are coarse.
logs = sorted(log_directory.glob('*-debug-0.log'))
if not logs:
return ''
lines = [line for line in logs[-1].read_text(encoding='utf-8', errors='replace').splitlines()
if re.search(r'oidc|trusted|http fetch|error', line, re.IGNORECASE)]
except OSError:
return ''
if not lines:
return ''
return f'\nnpm reported ({logs[-1].name}):\n' + '\n'.join(lines[-20:])

def publish_github(self) -> None:
tag = self.value('TAG')
prerelease = ['--prerelease'] if self.value('NPM_TAG') == 'next' else []
Expand Down
15 changes: 14 additions & 1 deletion scripts/tests/test_release_workflow_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_publication_reruns_skip_npm_and_update_github(self) -> None:
self.driver.publish_npm()
self.assertEqual(npm.call_count, 1 if exists else 2)
if not exists:
self.assertEqual(npm.call_args.args[0], ['npm', 'publish', 'fixture.tgz', '--access', 'public', '--tag', 'next'])
self.assertEqual(npm.call_args.args[0], ['npm', 'publish', 'fixture.tgz', '--access', 'public', '--tag', 'next', '--loglevel=http'])
with patch.object(self.driver, 'run', return_value=self.result(code=0 if exists else 1)) as run:
self.driver.publish_github()
commands = [call.args[0] for call in run.call_args_list]
Expand All @@ -231,6 +231,19 @@ def test_publication_reruns_skip_npm_and_update_github(self) -> None:
self.assertIn(str(Path('dist') / 'fixture.unitypackage.sha256'), commands[-1])
self.assertIn('--clobber' if exists else '--verify-tag', commands[-1])

def test_npm_debug_log_supplies_the_registry_reason(self) -> None:
logs = self.root / 'npm-logs'
logs.mkdir()
(logs / '2026-11-04T19_35_40_315Z-debug-0.log').write_text('npm http fetch POST 404 oidc stale\n', encoding='utf-8')
newest = logs / '2026-11-04T19_46_15_004Z-debug-0.log'
newest.write_text('npm info run\nnpm http fetch POST 404 https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/fixture\n'
'npm error code E404\n', encoding='utf-8')
report = self.driver.npm_debug_report(logs)
self.assertIn('19_46_15_004Z', report)
self.assertIn('oidc/token/exchange', report)
self.assertNotIn('stale', report)
self.assertEqual(self.driver.npm_debug_report(self.root / 'absent'), '')

def test_publication_failures_name_the_registry_answer(self) -> None:
self.driver.environment.update(PKG='fixture', VER='1.2.3', NPM_TAG='latest', PACKAGE_FILE='fixture.tgz',
GITHUB_REPOSITORY='owner/repository')
Expand Down
Loading