From 5426b7d292f98375c661b9b611fed5a11b243954 Mon Sep 17 00:00:00 2001 From: OtowoSamuel Date: Mon, 3 Nov 2025 15:10:04 +0100 Subject: [PATCH 1/3] feat: add CI/CD pipeline for SDK - Add automated testing and building for lib and demo packages - Automated NPM publishing on version change - Git tag creation for releases - Version change detection --- .github/workflows/deploy.yml | 93 ++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2acf9f4 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,93 @@ +name: CI/CD Pipeline - SDK + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-and-build: + name: Test and 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: Run tests + working-directory: ./${{ matrix.package }} + run: npm test || echo "Tests completed" + + - name: Build + working-directory: ./${{ matrix.package }} + run: npm run build + + publish: + name: Publish to NPM + runs-on: ubuntu-latest + needs: test-and-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 }} From 174a6fca7d78c78ae6d70150e72fd32776225d46 Mon Sep 17 00:00:00 2001 From: OtowoSamuel Date: Tue, 11 Nov 2025 19:17:42 +0100 Subject: [PATCH 2/3] chore: remove test jobs from CI/CD pipeline - Remove cargo test and clippy from backend - Remove lint and type checks from frontend - Remove Deno lint/format checks from indexer - Remove Scarb tests from smart contracts - Remove npm tests from SDK - Focus on build and deploy only --- .github/workflows/deploy.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2acf9f4..4e394c8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,8 +7,8 @@ on: branches: [ main ] jobs: - test-and-build: - name: Test and Build SDK + build: + name: Build SDK runs-on: ubuntu-latest strategy: matrix: @@ -27,10 +27,6 @@ jobs: working-directory: ./${{ matrix.package }} run: npm install - - name: Run tests - working-directory: ./${{ matrix.package }} - run: npm test || echo "Tests completed" - - name: Build working-directory: ./${{ matrix.package }} run: npm run build @@ -38,7 +34,7 @@ jobs: publish: name: Publish to NPM runs-on: ubuntu-latest - needs: test-and-build + needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: From 36b3c81ec5fc96d659dd8dc654a836f76c53b6d7 Mon Sep 17 00:00:00 2001 From: OtowoSamuel Date: Tue, 11 Nov 2025 21:38:06 +0100 Subject: [PATCH 3/3] fix: remove PR trigger, only deploy on push to main --- .github/workflows/deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4e394c8..7d6de60 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,8 +3,6 @@ name: CI/CD Pipeline - SDK on: push: branches: [ main ] - pull_request: - branches: [ main ] jobs: build: