Skip to content

Commit ae1a068

Browse files
committed
chore: compare local and regi version logic
1 parent 65ea88c commit ae1a068

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/deploy-package.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,18 @@ jobs:
5656
working-directory: packages/msw-dev-tool
5757
run: |
5858
CURRENT_VERSION=$(cat package.json | jq -r '.version')
59-
if [ "$CURRENT_VERSION" != "${{ env.npm_version }}" ]; then
60-
npm version ${{ env.npm_version }} --no-git-tag-version
59+
REGISTRY_VERSION=${{ env.npm_version }}
60+
61+
# Compare version
62+
function version_gt() {
63+
test "$(printf '%s\n' "$1" "$2" | sort -V | head -n 1)" != "$1"
64+
}
65+
66+
if version_gt "$CURRENT_VERSION" "$NPM_VERSION"; then
67+
echo "Local version: ($CURRENT_VERSION) is higher then registry version: ($NPM_VERSION). Maintain local version."
68+
elif [ "$CURRENT_VERSION" != "$NPM_VERSION" ]; then
69+
echo "Registry version: ($NPM_VERSION) is higher then ($CURRENT_VERSION). Update local version."
70+
npm version $NPM_VERSION --no-git-tag-version
6171
else
6272
echo "Versions are the same, no need to update."
6373
fi

0 commit comments

Comments
 (0)