From 6bb75fabe98d493e05d01d76b299c2ebac27e4e7 Mon Sep 17 00:00:00 2001 From: Mark McCulloh Date: Wed, 27 Sep 2023 13:41:24 -0400 Subject: [PATCH] chore: add retry for npm publish (#4309) I feel like there is a bug in NPM or the registry behind [this issue](https://github.com/winglang/wing/actions/runs/6327139430/job/17183678513), but idk what to do so let's add some retry. *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- .github/workflows/build.yml | 39 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 75a35520a44..fcee8b40fd7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -370,25 +370,30 @@ jobs: - name: Login to NPM registry run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_PUBLISH_TOKEN }} - - name: Publish npm packages - working-directory: dist + - name: Publish NPM packages + uses: nick-fields/retry@v2 env: PACKAGE_VERSION: ${{ needs.build.outputs.version }} - run: | - PACKAGES=("@winglang/sdk" "@winglang/compiler" "@wingconsole/design-system" "@wingconsole/ui" "@wingconsole/server" "@wingconsole/app" "winglang") - for PACKAGE in "${PACKAGES[@]}"; do - # Check if already published - VERSION_FOUND=$(npm view "$PACKAGE@$PACKAGE_VERSION" version || true) - if [ "$VERSION_FOUND" = "$PACKAGE_VERSION" ]; then - echo "$PACKAGE@$PACKAGE_VERSION already published, skipping" - continue - fi - - # remove "@" and replace "/" with "-" - TARBALL=$(echo "$PACKAGE-$PACKAGE_VERSION.tgz" | sed 's/@//g' | sed 's/\//-/g') - - npm publish "$TARBALL" --access public - done + with: + max_attempts: 7 + retry_on: error + timeout_minutes: 5 + command: | + cd dist + PACKAGES=("@winglang/sdk" "@winglang/compiler" "@wingconsole/design-system" "@wingconsole/ui" "@wingconsole/server" "@wingconsole/app" "winglang") + for PACKAGE in "${PACKAGES[@]}"; do + # Check if already published + VERSION_FOUND=$(npm view "$PACKAGE@$PACKAGE_VERSION" version --verbose || true) + if [ "$VERSION_FOUND" = "$PACKAGE_VERSION" ]; then + echo "$PACKAGE@$PACKAGE_VERSION already published, skipping" + continue + fi + + # remove "@" and replace "/" with "-" + TARBALL=$(echo "$PACKAGE-$PACKAGE_VERSION.tgz" | sed 's/@//g' | sed 's/\//-/g') + + npm publish "$TARBALL" --access public --verbose + done - name: Publish Extension to Visual Studio Marketplace if: needs.build.outputs.vscode-wing-changed == 'true'