From 5736ac456524e3a8c6d48815620852323538e4b1 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 5 Jan 2026 12:05:34 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Don't=20try=20to=20publish=20an?= =?UTF-8?q?=20NPM=20package=20if=20it=20exists=20already?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a problem when re-running task that if we try to publish a version to npm that does not exist yet, then it fails. However, we want attempts to publish to be idemponent. This adds a check step to see if the npm package at the specified name and version already exists. If so, then we skip publishing. --- .github/workflows/publish.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index de4f2cc..9f57efd 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -78,7 +78,21 @@ jobs: - run: deno run -A tasks/build-npm.ts ${{matrix.workspace}} + - name: Check if Published + id: checkIfPublished + run: | + PACKAGE="${{ matrix.name }}@${{ matrix.version }}" + + if npm view "$PACKAGE" version 2>/dev/null; then + echo "$PACKAGE exists, publishing will be skipped" + echo "publish=false" >> $GITHUB_OUTPUT + else + echo "$PACKAGE not found, will attempt to publish" + echo "publish=true" >> $GITHUB_OUTPUT + fi + - run: npm publish --access=public --tag=latest + if: steps.checkIfPublished.outputs.publish == 'true' working-directory: ${{matrix.workspace}}/build/npm tag: