@@ -39,24 +39,28 @@ jobs:
3939 git config --global core.autocrlf false
4040 git config --global core.eol lf
4141 - name : Checkout repository
42- uses : actions/checkout@v2
42+ uses : actions/checkout@v3
4343 - name : Check if Node.js project and has package.json
4444 id : packagejson
45- run : test -e ./package.json && echo "::set-output name= exists:: true" || echo "::set-output name= exists:: false"
45+ run : test -e ./package.json && echo "exists= true" >> $GITHUB_OUTPUT || echo "exists= false" >> $GITHUB_OUTPUT
4646 shell : bash
47+ - if : steps.packagejson.outputs.exists == 'true'
48+ name : Check package-lock version
49+ uses : asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
50+ id : lockversion
4751 - if : steps.packagejson.outputs.exists == 'true'
4852 name : Setup Node.js
49- uses : actions/setup-node@v2
53+ uses : actions/setup-node@v3
5054 with :
51- node-version : 14
55+ node-version : " ${{ steps.lockversion.outputs.version }} "
5256 cache : ' npm'
5357 cache-dependency-path : ' **/package-lock.json'
5458 - if : steps.packagejson.outputs.exists == 'true'
5559 name : Install dependencies
5660 run : npm install
5761 - if : steps.packagejson.outputs.exists == 'true'
5862 name : Run test
59- run : npm test
63+ run : npm test --if-present
6064 - if : failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
6165 name : Report workflow run status to Slack
6266 uses : 8398a7/action-slack@v3
@@ -69,26 +73,43 @@ jobs:
6973
7074 release :
7175 needs : [test-nodejs]
72- name : Publish to any of NPM, Github, and Docker Hub
76+ name : Publish to any of NPM, Github, or Docker Hub
7377 runs-on : ubuntu-latest
7478 steps :
7579 - name : Set git to use LF # to once and for all finish neverending fight between Unix and Windows
7680 run : |
7781 git config --global core.autocrlf false
7882 git config --global core.eol lf
7983 - name : Checkout repository
80- uses : actions/checkout@v2
84+ uses : actions/checkout@v3
8185 - name : Check if Node.js project and has package.json
8286 id : packagejson
83- run : test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
87+ run : test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
88+ shell : bash
89+ - if : steps.packagejson.outputs.exists == 'true'
90+ name : Check package-lock version
91+ uses : asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
92+ id : lockversion
8493 - if : steps.packagejson.outputs.exists == 'true'
8594 name : Setup Node.js
86- uses : actions/setup-node@v1
95+ uses : actions/setup-node@v3
8796 with :
88- node-version : 14
97+ node-version : " ${{ steps.lockversion.outputs.version }}"
98+ cache : ' npm'
99+ cache-dependency-path : ' **/package-lock.json'
89100 - if : steps.packagejson.outputs.exists == 'true'
90101 name : Install dependencies
91- run : npm install
102+ id : first-installation
103+ run : npm ci
104+ continue-on-error : true
105+ - if : steps.first-installation.outputs.status == 'failure' && steps.packagejson.outputs.exists == 'true'
106+ name : Clear NPM cache and install deps again
107+ run : |
108+ npm cache clean --force
109+ npm ci
110+ - if : steps.packagejson.outputs.exists == 'true'
111+ name : Add plugin for conventional commits for semantic-release
112+ run : npm install --save-dev conventional-changelog-conventionalcommits@5.0.0
92113 - if : steps.packagejson.outputs.exists == 'true'
93114 name : Publish to any of NPM, Github, and Docker Hub
94115 id : release
@@ -101,7 +122,7 @@ jobs:
101122 GIT_AUTHOR_EMAIL : info@asyncapi.io
102123 GIT_COMMITTER_NAME : asyncapi-bot
103124 GIT_COMMITTER_EMAIL : info@asyncapi.io
104- run : npm run release
125+ run : npx semantic- release@19.0.4
105126 - if : failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
106127 name : Report workflow run status to Slack
107128 uses : 8398a7/action-slack@v3
@@ -110,4 +131,4 @@ jobs:
110131 fields : repo,action,workflow
111132 text : ' Release workflow failed in release job'
112133 env :
113- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
134+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
0 commit comments