-
Notifications
You must be signed in to change notification settings - Fork 6
84 lines (67 loc) · 3.57 KB
/
dependency-update.yml
File metadata and controls
84 lines (67 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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"