From 6f309a0c1eb489f35559919cafff6cc9174bf25a Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 7 Mar 2023 13:32:06 -0500 Subject: [PATCH] release workflow fixes (#3045) --- .github/actions/publish-libs/action.yml | 39 ++++++++----------- .../update-library-versions/action.yml | 27 +++++++++++++ 2 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 .github/actions/update-library-versions/action.yml diff --git a/.github/actions/publish-libs/action.yml b/.github/actions/publish-libs/action.yml index 42ec5fc98..ee0460a26 100644 --- a/.github/actions/publish-libs/action.yml +++ b/.github/actions/publish-libs/action.yml @@ -30,25 +30,14 @@ inputs: runs: using: "composite" steps: - - run: npm ci + - uses: ./.github/actions/update-library-versions + name: Update Library Versions + with: + dry-run: ${{ inputs.dry-run }} + + - name: Build Libraries shell: bash - - name: Update Library Versions - shell: bash - run: | - VERSION_IN_PACKAGE_JSON=$(jq -cr '.version' < package.json) - - if [[ ${{ inputs.branch_name }} =~ ^master.*?$ ]] ; then - NEW_LIBRARY_VERSION="$VERSION_IN_PACKAGE_JSON" - else - NEW_LIBRARY_VERSION="${VERSION_IN_PACKAGE_JSON}-${{ github.run_id }}" - fi - - echo -e "Branch is '${{ inputs.branch_name }}, therefore publish with '${{ inputs.npm_tag }}' tag\n" - - ./scripts/gh/update-lib-versions.sh "$NEW_LIBRARY_VERSION" "${{ inputs.dry-run }}" - - echo "Building projects" - npm run build-libs + run: npm ci && npm run build-libs - uses: actions/setup-node@v3 name: setup GH registry @@ -56,11 +45,14 @@ runs: node-version-file: '.nvmrc' registry-url: 'https://npm.pkg.github.com' scope: '@alfresco' + - name: Publish to GH registry shell: bash - run: ./scripts/gh/npm-publish.sh "${{ inputs.npm_tag }}" "${{ inputs.dry-run }}" + run: ./scripts/gh/npm-publish.sh "$TAG" "$DRY_RUN" env: - NODE_AUTH_TOKEN: ${{ inputs.github_token }} + NODE_AUTH_TOKEN: ${{ inputs.github_token }} + TAG: ${{ inputs.npm_tag }} + DRY_RUN: ${{ inputs.dry-run }} - uses: actions/setup-node@v3 name: setup NPM registry @@ -68,8 +60,11 @@ runs: node-version-file: '.nvmrc' registry-url: 'https://${{ inputs.npm_registry_address }}' scope: '@alfresco' + - name: Publish to NPM registry shell: bash - run: ./scripts/gh/npm-publish.sh "${{ inputs.npm_tag }}" "${{ inputs.dry-run }}" + run: ./scripts/gh/npm-publish.sh "$TAG" "$DRY_RUN" env: - NODE_AUTH_TOKEN: ${{ inputs.npm_registry_token }} + NODE_AUTH_TOKEN: ${{ inputs.npm_registry_token }} + TAG: ${{ inputs.npm_tag }} + DRY_RUN: ${{ inputs.dry-run }} diff --git a/.github/actions/update-library-versions/action.yml b/.github/actions/update-library-versions/action.yml new file mode 100644 index 000000000..4e11cf095 --- /dev/null +++ b/.github/actions/update-library-versions/action.yml @@ -0,0 +1,27 @@ +name: "Update Library Versions" +description: "Updates ACA libraries according to the root Version" + +inputs: + dry-run: + description: dry run flag + required: true + type: boolean + +runs: + using: "composite" + steps: + - name: Update Versions + shell: bash + run: | + VERSION_IN_PACKAGE_JSON=$(jq -cr '.version' < package.json) + + if [[ ${{ inputs.branch_name }} =~ ^master.*?$ ]] ; then + NEW_LIBRARY_VERSION="$VERSION_IN_PACKAGE_JSON" + else + NEW_LIBRARY_VERSION="${VERSION_IN_PACKAGE_JSON}-${{ github.run_id }}" + fi + + ./scripts/gh/update-lib-versions.sh "$NEW_LIBRARY_VERSION" "${{ inputs.dry-run }}" + + echo "Building projects" + npm run build-libs