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
7 changes: 5 additions & 2 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ on:
release:
types: [published]

# One release per package arrives at once. Runs queue, so the first publishes every new version
# and the rest find nothing left to publish.
# The three packages share one version (linked-versions), so release-please publishes three
# GitHub releases at once. bin/publish-npm publishes every package whose version is new, so one
# run is enough: only voice-client's release runs the job, and the other two are skipped. Runs
# still queue, for a manual run that overlaps one.
concurrency:
group: publish-npm
cancel-in-progress: false

jobs:
publish:
name: publish
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'voice-client-v')
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
18 changes: 16 additions & 2 deletions bin/publish-npm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ for package in $(./scripts/utils/packages); do
PACKAGE_NAME="$(jq -r -e '.name' ./package.json)"
VERSION="$(jq -r -e '.version' ./package.json)"

if npm view "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
# --prefer-online skips npm's local cache. The registry itself can still lag a version that
# was published seconds ago, which the publish below allows for.
if npm view --prefer-online "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
echo "$PACKAGE_NAME@$VERSION is already published, skipping"
cd - >/dev/null
continue
Expand Down Expand Up @@ -57,6 +59,18 @@ for package in $(./scripts/utils/packages); do
TAG="latest"
fi

pnpm publish --npm-path "$NPM_PATH" --no-git-checks --tag "$TAG"
# npm refuses a version it already has with E409. Another run that published it moments ago
# is not a failure, so look again, for up to 30 seconds of registry lag, before failing.
if ! pnpm publish --npm-path "$NPM_PATH" --no-git-checks --tag "$TAG"; then
for _ in 1 2 3 4 5 6; do
if npm view --prefer-online "$PACKAGE_NAME@$VERSION" version >/dev/null 2>&1; then
echo "$PACKAGE_NAME@$VERSION was published by another run, skipping"
cd - >/dev/null
continue 2
fi
sleep 5
done
exit 1
fi
cd - >/dev/null
done
Loading