Skip to content

Check/Update SDK version #182

Check/Update SDK version

Check/Update SDK version #182

name: Check/Update SDK version
on:
workflow_dispatch: # Manual trigger
schedule: # Run daily at midnight and noon UTC
- cron: '0 0,12 * * *'
# Needed for create-pull-request
permissions:
contents: write
pull-requests: write
# Prevent overlapping runs
concurrency:
group: update-evo-sdk
cancel-in-progress: true
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: '20'
- name: Enable Corepack
run: corepack enable
- name: Check for new evo-sdk version
id: check_version
run: |
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').dependencies['@dashevo/evo-sdk']")
echo "Current version in package.json: $CURRENT_VERSION"
# Validate no version specifiers are present
if [[ "$CURRENT_VERSION" =~ ^[~\^\>\<=] ]]; then
echo "Error: Version specifiers detected in package.json: $CURRENT_VERSION"
echo "Only exact versions are allowed (e.g., '1.2.3', not '^1.2.3')"
exit 1
fi
# Get latest version from npm
LATEST_VERSION=$(npm view @dashevo/evo-sdk version)
echo "Latest version on npm: $LATEST_VERSION"
# Store versions for later steps
echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "latest=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
# Check if versions differ
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "needs_update=true" >> "$GITHUB_OUTPUT"
echo "New version available: $LATEST_VERSION"
else
echo "needs_update=false" >> "$GITHUB_OUTPUT"
echo "Already on latest version"
fi
- name: Install dependencies
if: steps.check_version.outputs.needs_update == 'true'
run: yarn install
- name: Upgrade evo-sdk
if: steps.check_version.outputs.needs_update == 'true'
run: |
echo "Upgrading @dashevo/evo-sdk to ${{ steps.check_version.outputs.latest }}"
yarn up @dashevo/evo-sdk@${{ steps.check_version.outputs.latest }}
- name: Verify package signatures
if: steps.check_version.outputs.needs_update == 'true'
run: |
echo "Verifying registry signatures and attestations..."
npm audit signatures || {
echo "Error: Package signature verification failed"
echo "This could indicate a compromised package or registry issue"
exit 1
}
- name: Run smoke tests
id: smoke_tests
if: steps.check_version.outputs.needs_update == 'true'
continue-on-error: true
run: |
echo "Installing Playwright browsers..."
npx playwright install --with-deps chromium
echo "Running smoke tests to verify compatibility..."
yarn test:smoke
- name: Run query tests
id: query_tests
if: steps.check_version.outputs.needs_update == 'true'
continue-on-error: true
run: |
echo "Running query tests to verify compatibility..."
yarn test:queries
- name: Create Pull Request
if: steps.check_version.outputs.needs_update == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
draft: ${{ steps.smoke_tests.outcome != 'success' || steps.query_tests.outcome != 'success' }}
branch: update-deps/evo-sdk-${{ steps.check_version.outputs.latest }}
title: "chore: upgrade evo-sdk to ${{ steps.check_version.outputs.latest }}"
body: |
This PR upgrades `@dashevo/evo-sdk` to the latest version available on npm.
**Version Change:**
- Previous: `${{ steps.check_version.outputs.current }}`
- New: `${{ steps.check_version.outputs.latest }}`
**Test Results:**
- Smoke tests: ${{ steps.smoke_tests.outcome == 'success' && '✅ Passed' || '❌ Failed' }}
- Query tests: ${{ steps.query_tests.outcome == 'success' && '✅ Passed' || '❌ Failed' }}
${{ steps.smoke_tests.outcome == 'success' && steps.query_tests.outcome == 'success' && '
✅ Smoke and query tests passed!' || format('
⚠️ **This PR is in draft because tests failed.**
Review the test failures in the [workflow run]({0}/{1}/actions/runs/{2}) and update the site code to support the new SDK version.', github.server_url, github.repository, github.run_id) }}
---
This PR was automatically created by the [update-evo-sdk workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/update-evo-sdk.yml).
commit-message: "chore: upgrade evo-sdk to ${{ steps.check_version.outputs.latest }}"
reviewers: "thephez,shumkov"
delete-branch: true
labels: dependencies,automated