Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(calimero-js-sdk): build and release only if package doesn't exist in the registry #394

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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