From 72686cc6f8a86e2d24a56f8bdce27d19ee6e0923 Mon Sep 17 00:00:00 2001 From: David Festal Date: Tue, 19 Sep 2023 15:16:15 +0200 Subject: [PATCH] Fix PR review comments Signed-off-by: David Festal --- .../publish-backend-plugin-manager.yaml | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-backend-plugin-manager.yaml b/.github/workflows/publish-backend-plugin-manager.yaml index 7c7a1ce926..3e35fbede1 100644 --- a/.github/workflows/publish-backend-plugin-manager.yaml +++ b/.github/workflows/publish-backend-plugin-manager.yaml @@ -15,6 +15,8 @@ name: Publish Backend Plugin Manager on: + push: + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -76,6 +78,20 @@ jobs: COMMIT_VERSION: ${{ steps.get_package_version.outputs.PACKAGE_VERSION }} LAST_PUSHED_VERSION: ${{ steps.get_last_pushed_version.outputs.LAST_PUSHED_VERSION }} run: | + # + # The new version to push to NPMS is calculated as follows: + # + # upstream version: 0.0.0, already pushed version: none => new version: 0.0.1-janus.0 + # upstream version: 0.0.0, already pushed version: 0.0.1-janus.0 => new version: 0.0.1-janus.1 + # upstream version: 0.0.1-next.0, already pushed version: 0.0.1-janus.1 => new version: 0.0.1-janus.2 + # upstream version: 0.0.1-next.1, already pushed version: 0.0.1-janus.2 => new version: 0.0.1-janus.3 + # upstream version: 0.0.1, already pushed version: 0.0.1-janus.3 => new version: 0.0.2-janus.0 + # upstream version: 0.0.2-next.0, already pushed version: 0.0.2-janus.0 => new version: 0.0.2-janus.1 + # etc ... + # + + # Parse the semantic version of the upstream `backend-plugin-manager` + COMMIT_MAJOR=$(echo $COMMIT_VERSION | cut -d. -f1) COMMIT_MINOR=$(echo $COMMIT_VERSION | cut -d. -f2) COMMIT_PATCH=$(echo $COMMIT_VERSION | cut -d. -f3 | cut -d- -f1) @@ -86,11 +102,19 @@ jobs: COMMIT_PRERELEASE=$(echo $COMMIT_VERSION | cut -d- -f2) fi + # If there is a pre-release part, then the effective last released version is the previous one + if [ -n "$COMMIT_PRERELEASE" ]; then COMMIT_PATCH=$((COMMIT_PATCH-1)) fi + # The PATCH part of the version pushed to NPMJS will always contain a pre-release part + # => increment it + PATCH=$((COMMIT_PATCH+1)) + + # If the last pushed version is not empty, set it to a default value, and then parse it + if [ -z "$LAST_PUSHED_VERSION" ]; then LAST_PUSHED_VERSION=$COMMIT_MAJOR.$COMMIT_MINOR.$PATCH-janus.0 fi @@ -101,6 +125,10 @@ jobs: LAST_PUSHED_PRERELEASE_WITHOUT_NUMBER=$(echo $LAST_PUSHED_VERSION | cut -d- -f2 | cut -d. -f1) LAST_PUSHED_PRERELEASE_NUMBER=$(echo $LAST_PUSHED_VERSION | cut -d- -f2 | cut -d. -f2) + # if base version (without pre-release part) is the same for upstream package and pushed NPM package, + # then just increment the pre-release number, + # otherwise, use the base version of the upstream package, and reset the `.janus.` pre-release number to 0. + if [ "$COMMIT_MAJOR.$COMMIT_MINOR.$PATCH" == "$LAST_PUSHED_MAJOR.$LAST_PUSHED_MINOR.$LAST_PUSHED_PATCH" ]; then PRERELEASE="janus.$((LAST_PUSHED_PRERELEASE_NUMBER+1))" else @@ -123,7 +151,7 @@ jobs: env: YARN_ENABLE_IMMUTABLE_INSTALLS: 'false' if: steps.test_commit_already_published.outputs.ALREADY_PUSHED == 'false' - run: yarn install + run: yarn install --prefer-offline --frozen-lockfile - name: Build the backend-plugin-manager package if: steps.test_commit_already_published.outputs.ALREADY_PUSHED == 'false'