Skip to content

Commit

Permalink
ci(calimero-js-sdk): build and release only if package doesn't exist …
Browse files Browse the repository at this point in the history
…in the registry (#394)
  • Loading branch information
fbozic authored Jun 19, 2024
1 parent 25113ef commit bc58349
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion .github/workflows/calimero_sdk_publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Calimero SDK
name: Publish Calimero JavaScript SDK

on:
push:
Expand All @@ -9,8 +9,38 @@ on:
workflow_dispatch:

jobs:
metadata:
name: Get package metadata
runs-on: ubuntu-latest
outputs:
package_exists: ${{ steps.check_release.outputs.exists }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
scope: "@calimero-is-near"

- name: Check if release exists
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PACKAGE_VERSION=$(node -p "require('./packages/calimero-sdk/package.json').version")
REGISTRY_VERSION=$(npm view @calimero-is-near/calimero-p2p-sdk@$VERSION version)
if [[ "$PACKAGE_VERSION" == "$REGISTRY_VERSION" ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
publish:
name: Build and release
runs-on: ubuntu-latest
needs: metadata
if: needs.metadata.outputs.package_exists == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
Expand Down

0 comments on commit bc58349

Please sign in to comment.