Skip to content
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
87 changes: 87 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI/CD Pipeline - SDK

on:
push:
branches: [ main ]

jobs:
build:
name: Build SDK
runs-on: ubuntu-latest
strategy:
matrix:
package: [lib, demo]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
working-directory: ./${{ matrix.package }}
run: npm install

- name: Build
working-directory: ./${{ matrix.package }}
run: npm run build

publish:
name: Publish to NPM
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
working-directory: ./lib
run: npm install

- name: Build
working-directory: ./lib
run: npm run build

- name: Check if version changed
id: version_check
working-directory: ./lib
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
PUBLISHED_VERSION=$(npm view $(node -p "require('./package.json').name") version 2>/dev/null || echo "0.0.0")
if [ "$PACKAGE_VERSION" != "$PUBLISHED_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "New version detected: $PACKAGE_VERSION (published: $PUBLISHED_VERSION)"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "Version unchanged: $PACKAGE_VERSION"
fi

- name: Publish to NPM
if: steps.version_check.outputs.changed == 'true'
working-directory: ./lib
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Git Tag
if: steps.version_check.outputs.changed == 'true'
working-directory: ./lib
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
git config user.name github-actions
git config user.email github-actions@github.com
git tag -a "v$PACKAGE_VERSION" -m "Release v$PACKAGE_VERSION"
git push origin "v$PACKAGE_VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}