From e103a9c553578785405bcdccf3ba2c36fad0eb35 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 10 Oct 2026 16:48:53 +0200 Subject: [PATCH] Skip already-published npm packages in release workflow Allows re-running the npm binary publish job after a partial failure. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/release.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50026885f..7158f2c28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -194,16 +194,28 @@ jobs: -d "$GITHUB_WORKSPACE/stylua-npm-bin/platforms/$PLATFORM/" done + # Skip versions that are already on the registry so a failed run can be re-run - name: Publish platform packages to npm run: | for PLATFORM in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64; do cd "$GITHUB_WORKSPACE/stylua-npm-bin/platforms/$PLATFORM" - npm publish + SPEC="$(node -p "require('./package.json').name + '@' + require('./package.json').version")" + if npm view "$SPEC" version >/dev/null 2>&1; then + echo "$SPEC is already published, skipping" + else + npm publish + fi done - name: Publish main package to npm working-directory: stylua-npm-bin - run: npm publish + run: | + SPEC="$(node -p "require('./package.json').name + '@' + require('./package.json').version")" + if npm view "$SPEC" version >/dev/null 2>&1; then + echo "$SPEC is already published, skipping" + else + npm publish + fi release_docker: name: Publish image to container registry