Update @dashevo/evo-sdk Dependency and Package Version #115
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update @dashevo/evo-sdk Dependency and Package Version | |
| on: | |
| schedule: | |
| - cron: '0 12 * * *' # Run daily at 1200 UTC | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-evo-sdk-package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| # Step 2: Set up Node.js | |
| - name: Set up Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: '20' | |
| # Step 3: Install dependencies | |
| - name: Install Dependencies | |
| run: npm install | |
| # Step 4: Check and Update @dashevo/evo-sdk Dependency and Version | |
| - name: Check and Update @dashevo/evo-sdk Dependency | |
| id: update_evo_sdk | |
| run: | | |
| set -e # Stop execution on any error | |
| # Get the installed version from the lockfile (not the declared specifier) | |
| INSTALLED_VERSION=$(npm ls @dashevo/evo-sdk --json | jq -r '.dependencies["@dashevo/evo-sdk"].version') | |
| CURRENT_DASH_VERSION=$(jq -r '.dependencies["@dashevo/evo-sdk"] // .devDependencies["@dashevo/evo-sdk"]' package.json) | |
| DASH_PREFIX=$(echo "$CURRENT_DASH_VERSION" | grep -o '^[^0-9]*') | |
| # Get the latest version of Dash | |
| LATEST_DASH_VERSION=$(npm show @dashevo/evo-sdk version) | |
| LATEST_MINOR_PATCH=$(echo "$LATEST_DASH_VERSION" | cut -d. -f2,3) | |
| echo "Installed @dashevo/evo-sdk version: $INSTALLED_VERSION" | |
| echo "Latest @dashevo/evo-sdk version: $LATEST_DASH_VERSION" | |
| # Only update if the latest stable version is strictly higher than installed | |
| # npx semver returns the version if it satisfies the range, empty otherwise | |
| IS_HIGHER=$(npx -y semver "$LATEST_DASH_VERSION" -r ">$INSTALLED_VERSION" || true) | |
| if [ -n "$IS_HIGHER" ]; then | |
| jq '.dependencies["@dashevo/evo-sdk"] = "'"$DASH_PREFIX$LATEST_DASH_VERSION"'"' package.json > package.json.tmp && mv package.json.tmp package.json | |
| # Update package version in package.json (keep major version, sync minor and patch) | |
| CURRENT_PACKAGE_VERSION=$(jq -r '.version' package.json) | |
| CURRENT_MAJOR_VERSION=$(echo "$CURRENT_PACKAGE_VERSION" | cut -d. -f1) | |
| NEW_PACKAGE_VERSION="$CURRENT_MAJOR_VERSION.$LATEST_MINOR_PATCH" | |
| jq '.version = "'"$NEW_PACKAGE_VERSION"'"' package.json > package.json.tmp && mv package.json.tmp package.json | |
| echo "Updated package.json version to $NEW_PACKAGE_VERSION" | |
| npm install @dashevo/evo-sdk | |
| echo "needs_update=true" >> $GITHUB_ENV | |
| else | |
| echo "@dashevo/evo-sdk dependency is up-to-date" | |
| echo "needs_update=false" >> $GITHUB_ENV | |
| fi | |
| # Step 5: Create Pull Request | |
| - name: Create Pull Request | |
| if: env.needs_update == 'true' | |
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: update-evo-sdk-and-version | |
| base: main | |
| title: "chore: update @dashevo/evo-sdk dependency and sync version" | |
| body: | | |
| This pull request updates the `@dashevo/evo-sdk` dependency to the latest version and syncs the package version, aligning the minor and patch versions with `@dashevo/evo-sdk`. | |
| commit-message: "chore: update @dashevo/evo-sdk dependency and sync version" | |
| reviewers: "thephez" |