From 802c56384b0b3329f0cba3a20ac75e96140cf836 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Wed, 19 Jul 2023 11:40:25 +0000 Subject: [PATCH] ci: update of files from global .github repo --- .github/workflows/bump.yml | 8 ++--- .github/workflows/if-nodejs-release.yml | 33 +++++++++++++------- .github/workflows/if-nodejs-version-bump.yml | 30 +++++++++++++++--- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index 68daa7c0cbd..92fa275ed45 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -20,15 +20,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check if Node.js project and has package.json id: packagejson - run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT - if: steps.packagejson.outputs.exists == 'true' name: Bumping latest version of this package in other repositories - uses: derberg/npm-dependency-manager-for-your-github-org@v4 + uses: derberg/npm-dependency-manager-for-your-github-org@26a4f13d740254719971325046822a169aaa7441 # using v5.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v5.0.0 with: github_token: ${{ secrets.GH_TOKEN }} committer_username: asyncapi-bot committer_email: info@asyncapi.io - repos_to_ignore: html-template # this is temporary until react component releases 1.0, then it can be removed + repos_to_ignore: html-template # this is temporary until react component releases 1.0, then it can be removed \ No newline at end of file diff --git a/.github/workflows/if-nodejs-release.yml b/.github/workflows/if-nodejs-release.yml index 3ff5467aa52..4938a37dadc 100644 --- a/.github/workflows/if-nodejs-release.yml +++ b/.github/workflows/if-nodejs-release.yml @@ -39,16 +39,20 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check if Node.js project and has package.json id: packagejson - run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT shell: bash + - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock version + uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master + id: lockversion - if: steps.packagejson.outputs.exists == 'true' name: Setup Node.js uses: actions/setup-node@v3 with: - node-version: 18 + node-version: "${{ steps.lockversion.outputs.version }}" cache: 'npm' cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' @@ -56,7 +60,7 @@ jobs: run: npm install - if: steps.packagejson.outputs.exists == 'true' name: Run test - run: npm test + run: npm test --if-present - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel name: Report workflow run status to Slack uses: 8398a7/action-slack@v3 @@ -69,7 +73,7 @@ jobs: release: needs: [test-nodejs] - name: Publish to any of NPM, Github, and Docker Hub + name: Publish to any of NPM, Github, or Docker Hub runs-on: ubuntu-latest steps: - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows @@ -77,20 +81,27 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check if Node.js project and has package.json id: packagejson - run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT + - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock version + uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master + id: lockversion - if: steps.packagejson.outputs.exists == 'true' name: Setup Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: - node-version: 18 + node-version: "${{ steps.lockversion.outputs.version }}" cache: 'npm' cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies run: npm install + - if: steps.packagejson.outputs.exists == 'true' + name: Add plugin for conventional commits for semantic-release + run: npm install --save-dev conventional-changelog-conventionalcommits@5.0.0 - if: steps.packagejson.outputs.exists == 'true' name: Publish to any of NPM, Github, and Docker Hub id: release @@ -103,7 +114,7 @@ jobs: GIT_AUTHOR_EMAIL: info@asyncapi.io GIT_COMMITTER_NAME: asyncapi-bot GIT_COMMITTER_EMAIL: info@asyncapi.io - run: npm run release + run: npx semantic-release@19.0.4 - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel name: Report workflow run status to Slack uses: 8398a7/action-slack@v3 @@ -112,4 +123,4 @@ jobs: fields: repo,action,workflow text: 'Release workflow failed in release job' env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} \ No newline at end of file + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} diff --git a/.github/workflows/if-nodejs-version-bump.yml b/.github/workflows/if-nodejs-version-bump.yml index 721caa9d737..7e27f90bbd7 100644 --- a/.github/workflows/if-nodejs-version-bump.yml +++ b/.github/workflows/if-nodejs-version-bump.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases # in case release is created from release branch then we need to checkout from given branch @@ -23,13 +23,24 @@ jobs: ref: ${{ github.event.release.target_commitish }} - name: Check if Node.js project and has package.json id: packagejson - run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" + run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT + - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock version + uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master + id: lockversion + - if: steps.packagejson.outputs.exists == 'true' + name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "${{ steps.lockversion.outputs.version }}" + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies run: npm install - if: steps.packagejson.outputs.exists == 'true' name: Assets generation - run: npm run generate:assets + run: npm run generate:assets --if-present - if: steps.packagejson.outputs.exists == 'true' name: Bump version in package.json # There is no need to substract "v" from the tag as version script handles it @@ -38,7 +49,7 @@ jobs: run: VERSION=${{github.event.release.tag_name}} npm run bump:version - if: steps.packagejson.outputs.exists == 'true' name: Create Pull Request with updated asset files including package.json - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4 with: token: ${{ secrets.GH_TOKEN }} commit-message: 'chore(release): ${{github.event.release.tag_name}}' @@ -46,4 +57,13 @@ jobs: author: asyncapi-bot title: 'chore(release): ${{github.event.release.tag_name}}' body: 'Version bump in package.json for release [${{github.event.release.tag_name}}](${{github.event.release.html_url}})' - branch: version-bump/${{github.event.release.tag_name}} \ No newline at end of file + branch: version-bump/${{github.event.release.tag_name}} + - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel + name: Report workflow run status to Slack + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,action,workflow + text: 'Unable to bump the version in package.json after the release' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} \ No newline at end of file