From 4dbb219e4aa14b365557e85a952ad2b7d5089f11 Mon Sep 17 00:00:00 2001 From: Damien LACHAUME / PALO-IT Date: Mon, 4 Mar 2024 15:54:43 +0100 Subject: [PATCH] Add new npm package step dedicated to release process --- .../actions/publish-npm-package/action.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions/publish-npm-package/action.yml b/.github/workflows/actions/publish-npm-package/action.yml index 045f1ddd842..08563fcee25 100644 --- a/.github/workflows/actions/publish-npm-package/action.yml +++ b/.github/workflows/actions/publish-npm-package/action.yml @@ -70,8 +70,8 @@ runs: cd ${{ inputs.package }}/pkg npm publish --tag ${{ inputs.tag }} --access ${{ inputs.access }} --dry-run - - name: Publish package - if: inputs.dry_run == 'false' && steps.check_version.outputs.should_deploy == 'true' + - name: Publish package new version + if: inputs.dry_run == 'false' && steps.check_version.outputs.should_deploy == 'true' && inputs.tag != 'latest' shell: bash env: NPM_TOKEN: ${{ inputs.api_token }} @@ -81,3 +81,17 @@ runs: npm whoami cd ${{ inputs.package }}/pkg npm publish --tag ${{ inputs.tag }} --access ${{ inputs.access }} + + - name: Promote package distribution tag to 'latest' + if: inputs.dry_run == 'false' && steps.check_version.outputs.should_deploy == 'true' && inputs.tag == 'latest' + shell: bash + env: + NPM_TOKEN: ${{ inputs.api_token }} + run: | + echo "Publish '@${{ inputs.scope }}/${{ inputs.package }}' package" + npm set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" + npm whoami + cd ${{ inputs.package }}/pkg + PACKAGE_VERSION=$(npm pkg get version | tr -d '"') + npm dist-tag add @${{ inputs.scope }}/${{ inputs.package }}@$PACKAGE_VERSION latest + npm dist-tag rm @${{ inputs.scope }}/${{ inputs.package }}@$PACKAGE_VERSION next