From e24c1804548239e64c877226752a07be15c54508 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Tue, 29 Dec 2020 12:54:17 +0300 Subject: [PATCH] change increment algorithm --- .github/workflows/publish_release.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 729eac2..81869a6 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -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 }}