Skip to content

Commit 2ea5b6e

Browse files
committed
Capture npm publish failure details in workflow
1 parent 4f3204b commit 2ea5b6e

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/publish-npm.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,34 @@ jobs:
300300
run: npm pack --dry-run
301301

302302
- name: Publish package
303+
id: publish_package
303304
working-directory: bindings/javascript
305+
continue-on-error: true
304306
env:
305307
NPM_CONFIG_PROVENANCE: true
308+
NPM_CONFIG_LOGLEVEL: verbose
309+
shell: bash
306310
run: |
307-
npm publish --access public --provenance
311+
set -o pipefail
312+
npm publish --access public --provenance 2>&1 | tee "$RUNNER_TEMP/npm-publish.log"
313+
314+
- name: Surface publish failure
315+
if: steps.publish_package.outcome != 'success'
316+
shell: bash
317+
run: |
318+
LOG_FILE="$RUNNER_TEMP/npm-publish.log"
319+
if [ -f "$LOG_FILE" ]; then
320+
tail -n 200 "$LOG_FILE"
321+
mapfile -t lines < <(grep -E 'npm error|npm warn|ERR!|E[0-9A-Z]+|404|auth|trusted|provenance|repository' "$LOG_FILE" | tail -n 20 || true)
322+
if [ "${#lines[@]}" -eq 0 ]; then
323+
mapfile -t lines < <(tail -n 20 "$LOG_FILE")
324+
fi
325+
for line in "${lines[@]}"; do
326+
clean_line="${line//$'\r'/}"
327+
echo "::error title=npm publish::${clean_line}"
328+
done
329+
fi
330+
exit 1
308331
309332
skip:
310333
needs: preflight

0 commit comments

Comments
 (0)