diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e69854a..c4ea73f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,19 @@ jobs: - uses: actions/setup-node@v4 with: registry-url: "https://registry.npmjs.org" - - run: yarn - - run: yarn publish + + - name: Check publish status + id: check + run: | + NEXT_VERSION=$(jq -r '.version' < packages/garbo-lib/package.json) + STATUS=$(curl --write-out '%{http_code}\n' --head --silent --output /dev/null https://registry.npmjs.org/garbo-lib/$NEXT_VERSION) + echo "status=$STATUS" >> "$GITHUB_OUTPUT" + + - name: Publish if necessary + if: ${{ steps.check.outputs.status == '404' }} + run: | + yarn + yarn npm publish env: + STATUS: ${{ steps.check.outputs.status }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}