Skip to content
Merged
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
36 changes: 30 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ jobs:
printf '//registry.npmjs.org/:_authToken=%s\n' "$NODE_AUTH_TOKEN" >> "$HOME/.npmrc"
npm whoami

# npm holds a freshly published version in a "Validating" state for
# minutes, during which `npm view` cannot resolve it. Verifying here
# used to fail the whole job and skip the CDN deploy and GitHub release
# for a publish that had in fact succeeded, so resolution is checked in
# the separate `npm-verify` job, which does not gate anything.
- name: Publish if this version is not on npm yet
id: npm
env:
Expand All @@ -154,19 +159,38 @@ jobs:
echo "skipped=false" >> "$GITHUB_OUTPUT"
fi

# Checked afterwards rather than trusting the publish step's exit code:
# `pnpm publish` can exit 0 without publishing anything.
npm-verify:
name: Verify npm resolution
needs: publish
runs-on: ubuntu-latest
steps:
# Runs after `publish` but gates nothing: the CDN deploy and GitHub
# release only need `publish`, so npm's validation queue can no longer
# stall them. A real failure still turns this job red and opens an issue.
# Both the version metadata and the tarball are probed — the metadata
# can resolve while the tarball still 404s during validation.
- name: Verify the version resolves on npm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
for attempt in 1 2 3 4 5 6; do
if [ "$(npm view "@devschile/chucao@$RELEASE_TAG" version 2>/dev/null)" = "$RELEASE_TAG" ]; then
deadline=$((SECONDS + 360))
while [ "$SECONDS" -lt "$deadline" ]; do
tarball=$(npm view "@devschile/chucao@$RELEASE_TAG" dist.tarball 2>/dev/null || true)
if [ -n "$tarball" ] && curl -sf -o /dev/null -r 0-0 "$tarball"; then
echo "$RELEASE_TAG resolves on npm"
exit 0
fi
sleep 10
sleep 30
done
echo "::error::$RELEASE_TAG is not resolvable on npm after publish"
echo "::error::$RELEASE_TAG did not resolve on npm within 6 minutes of publish"
title="npm publish verification failed for $RELEASE_TAG"
open=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open \
--search "in:title $RELEASE_TAG" --json number --jq 'length')
if [ "$open" = "0" ]; then
gh issue create --repo "$GITHUB_REPOSITORY" --title "$title" --label bug \
--body "The publish job reported success for tag \`$RELEASE_TAG\`, but \`@devschile/chucao@$RELEASE_TAG\` did not resolve on npm (version metadata and tarball probed) within 6 minutes. npm may still be validating the release — check https://www.npmjs.com/package/@devschile/chucao?activeTab=versions — or the publish may have silently failed, in which case re-dispatch the Release workflow for this tag."
fi
exit 1

cdn:
Expand Down
Loading