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
17 changes: 13 additions & 4 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ jobs:
if: ${{ !inputs.dryRun && steps.plan.outputs.bootstrap != '[]' }}
env:
PACKAGES: ${{ steps.plan.outputs.bootstrap }}
WORKFLOW_REF: ${{ github.workflow_ref }}
run: |
set -euo pipefail
{
Expand All @@ -347,8 +348,10 @@ jobs:
echo
# shellcheck disable=SC2016
node --input-type=module -e '
// npm records the workflow that calls this one, not this workflow.
const workflow = process.env.WORKFLOW_REF.split("@")[0].split("/").pop()
for (const name of JSON.parse(process.env.PACKAGES)) {
console.log(` npm trust github ${name} --repository ${process.env.GITHUB_REPOSITORY} --file deployment.yml --allow-publish --yes`)
console.log(` npm trust github ${name} --repository ${process.env.GITHUB_REPOSITORY} --file ${workflow} --allow-publish --yes`)
}
'
echo
Expand All @@ -364,12 +367,18 @@ jobs:
PACKAGE_LINES="$(node --input-type=module -e 'for (const name of JSON.parse(process.env.PACKAGES)) console.log(name)')"
mapfile -t PACKAGE_NAMES <<< "$PACKAGE_LINES"
for PACKAGE_NAME in "${PACKAGE_NAMES[@]}"; do
for ATTEMPT in {1..6}; do
if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version >/dev/null; then
# Read the version document rather than the package document. The release plan reads the
# package document before publishing, so for a package published for the first time the
# registry caches that 404 and keeps serving it long after the publication succeeded.
ENCODED_NAME="$(node --input-type=module -e 'console.log(encodeURIComponent(process.argv[1]))' "$PACKAGE_NAME")"
DEADLINE="$(($(date +%s) + 300))"
while true; do
if curl -fsS --connect-timeout 10 --max-time 30 -o /dev/null \
"https://registry.npmjs.org/$ENCODED_NAME/$PACKAGE_VERSION"; then
echo "Verified $PACKAGE_NAME@$PACKAGE_VERSION."
break
fi
if [ "$ATTEMPT" -eq 6 ]; then
if [ "$(date +%s)" -ge "$DEADLINE" ]; then
echo "Unable to verify $PACKAGE_NAME@$PACKAGE_VERSION on npm."
exit 1
fi
Expand Down
Loading