change increment algorithm

This commit is contained in:
folex 2020-12-29 12:54:17 +03:00
parent 8a91187bdb
commit e24c180454

View File

@ -26,12 +26,20 @@ jobs:
set -x
yarn global add semver
PATH="$(yarn global bin):$PATH"
LOCAL_VERSION="$(cat package.json | jq -r .version)"
# take npm version and increment it
PKG_NAME="$(cat package.json | jq .name)"
NPM_VERSION="$(yarn info --silent "$PKG_NAME" version || true)"
MAX_VERSION="$(semver "$LOCAL_VERSION" "$NPM_VERSION" "0.0.0" | tail -n1)"
FINAL_VERSION="$(semver --increment patch "$MAX_VERSION")"
echo "FINAL_VERSION=$FINAL_VERSION" | tee -a $GITHUB_ENV
NEXT_NPM_VERSION="$(semver --increment patch "$NPM_VERSION")"
# take local version
LOCAL_VERSION="$(cat package.json | jq -r .version)"
# take maximum of the local and NEXT_NPM versions
MAX_VERSION="$(semver "$LOCAL_VERSION" "$NEXT_NPM_VERSION" "0.0.0" | tail -n1)"
# save version to env
echo "FINAL_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
### Set version
- name: Set version to ${{ env.FINAL_VERSION }}