Skip to content

Commit 233901b

Browse files
thephezclaude
andauthored
ci: update dependency check for correct package (#56)
* ci: update dependency workflow for @dashevo/evo-sdk * ci: prevent dependency workflow from downgrading to older stable versions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: pin actions * ci: check installed version instead of package.json --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 728b7a3 commit 233901b

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Dash Dependency and Package Version
1+
name: Update @dashevo/evo-sdk Dependency and Package Version
22

33
on:
44
schedule:
@@ -10,47 +10,48 @@ permissions:
1010
pull-requests: write
1111

1212
jobs:
13-
update-dash-package:
13+
update-evo-sdk-package:
1414
runs-on: ubuntu-latest
1515

1616
steps:
1717
# Step 1: Checkout the repository
1818
- name: Checkout Repository
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020

2121
# Step 2: Set up Node.js
2222
- name: Set up Node.js
23-
uses: actions/setup-node@v4
23+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
2424
with:
2525
node-version: '20'
2626

2727
# Step 3: Install dependencies
2828
- name: Install Dependencies
2929
run: npm install
3030

31-
# Step 4: Check and Update Dash Dependency and Version
32-
- name: Check and Update Dash Dependency
33-
id: update_dash
31+
# Step 4: Check and Update @dashevo/evo-sdk Dependency and Version
32+
- name: Check and Update @dashevo/evo-sdk Dependency
33+
id: update_evo_sdk
3434
run: |
3535
set -e # Stop execution on any error
3636
37-
# Get the current version of Dash in package.json
38-
CURRENT_DASH_VERSION=$(jq -r '.dependencies.dash // .devDependencies.dash' package.json)
39-
40-
# Extract the version prefix (e.g., ^, ~, or empty)
37+
# Get the installed version from the lockfile (not the declared specifier)
38+
INSTALLED_VERSION=$(npm ls @dashevo/evo-sdk --json | jq -r '.dependencies["@dashevo/evo-sdk"].version')
39+
CURRENT_DASH_VERSION=$(jq -r '.dependencies["@dashevo/evo-sdk"] // .devDependencies["@dashevo/evo-sdk"]' package.json)
4140
DASH_PREFIX=$(echo "$CURRENT_DASH_VERSION" | grep -o '^[^0-9]*')
42-
DASH_VERSION_NUMBER=$(echo "$CURRENT_DASH_VERSION" | grep -o '[0-9].*')
4341
4442
# Get the latest version of Dash
45-
LATEST_DASH_VERSION=$(npm show dash version)
43+
LATEST_DASH_VERSION=$(npm show @dashevo/evo-sdk version)
4644
LATEST_MINOR_PATCH=$(echo "$LATEST_DASH_VERSION" | cut -d. -f2,3)
4745
48-
echo "Current Dash version: $CURRENT_DASH_VERSION"
49-
echo "Latest Dash version: $LATEST_DASH_VERSION"
46+
echo "Installed @dashevo/evo-sdk version: $INSTALLED_VERSION"
47+
echo "Latest @dashevo/evo-sdk version: $LATEST_DASH_VERSION"
5048
51-
# Update dash dependency if needed
52-
if [ "$DASH_VERSION_NUMBER" != "$LATEST_DASH_VERSION" ]; then
53-
jq '.dependencies.dash = "'"$DASH_PREFIX$LATEST_DASH_VERSION"'"' package.json > package.json.tmp && mv package.json.tmp package.json
49+
# Only update if the latest stable version is strictly higher than installed
50+
# npx semver returns the version if it satisfies the range, empty otherwise
51+
IS_HIGHER=$(npx -y semver "$LATEST_DASH_VERSION" -r ">$INSTALLED_VERSION" || true)
52+
53+
if [ -n "$IS_HIGHER" ]; then
54+
jq '.dependencies["@dashevo/evo-sdk"] = "'"$DASH_PREFIX$LATEST_DASH_VERSION"'"' package.json > package.json.tmp && mv package.json.tmp package.json
5455
5556
# Update package version in package.json (keep major version, sync minor and patch)
5657
CURRENT_PACKAGE_VERSION=$(jq -r '.version' package.json)
@@ -60,24 +61,24 @@ jobs:
6061
jq '.version = "'"$NEW_PACKAGE_VERSION"'"' package.json > package.json.tmp && mv package.json.tmp package.json
6162
echo "Updated package.json version to $NEW_PACKAGE_VERSION"
6263
63-
npm install dash
64+
npm install @dashevo/evo-sdk
6465
6566
echo "needs_update=true" >> $GITHUB_ENV
6667
else
67-
echo "Dash dependency is up-to-date"
68+
echo "@dashevo/evo-sdk dependency is up-to-date"
6869
echo "needs_update=false" >> $GITHUB_ENV
6970
fi
7071
7172
# Step 5: Create Pull Request
7273
- name: Create Pull Request
7374
if: env.needs_update == 'true'
74-
uses: peter-evans/create-pull-request@v5
75+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
7576
with:
7677
token: ${{ secrets.GITHUB_TOKEN }}
77-
branch: update-dash-and-version
78+
branch: update-evo-sdk-and-version
7879
base: main
79-
title: "chore: update Dash dependency and sync version"
80+
title: "chore: update @dashevo/evo-sdk dependency and sync version"
8081
body: |
81-
This pull request updates the `dash` dependency to the latest version and syncs the package version, aligning the minor and patch versions with `dash`.
82-
commit-message: "chore: update Dash dependency and sync version"
82+
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`.
83+
commit-message: "chore: update @dashevo/evo-sdk dependency and sync version"
8384
reviewers: "thephez"

0 commit comments

Comments
 (0)