Skip to content

Check/Update SDK version #573

Check/Update SDK version

Check/Update SDK version #573

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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '22'
- 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"
# Only update if the latest stable version is strictly higher than current
# npx semver returns the version if it satisfies the range, empty otherwise
IS_HIGHER=$(npx -y semver@7.7.4 "$LATEST_VERSION" -r ">$CURRENT_VERSION" || true)
if [ -n "$IS_HIGHER" ]; then
echo "needs_update=true" >> "$GITHUB_OUTPUT"
echo "New version available: $LATEST_VERSION"
else
echo "needs_update=false" >> "$GITHUB_OUTPUT"
echo "Current version ($CURRENT_VERSION) is same or newer than latest ($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 unit tests
id: unit_tests
if: steps.check_version.outputs.needs_update == 'true'
continue-on-error: true
run: |
echo "Running unit tests to verify generated documentation and SDK compatibility..."
yarn test:unit
- 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@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
draft: ${{ steps.unit_tests.outcome != 'success' || 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:**
- Unit tests: ${{ steps.unit_tests.outcome == 'success' && '✅ Passed' || '❌ Failed' }}
- Smoke tests: ${{ steps.smoke_tests.outcome == 'success' && '✅ Passed' || '❌ Failed' }}
- Query tests: ${{ steps.query_tests.outcome == 'success' && '✅ Passed' || '❌ Failed' }}
${{ steps.unit_tests.outcome == 'success' && steps.smoke_tests.outcome == 'success' && steps.query_tests.outcome == 'success' && '
✅ Unit, 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