Skip to content

Commit

Permalink
chore: add retry for npm publish (#4309)
Browse files Browse the repository at this point in the history
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)*.
  • Loading branch information
MarkMcCulloh authored Sep 27, 2023
1 parent 6d29256 commit 6bb75fa
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6bb75fa

Please sign in to comment.