@@ -39,24 +39,28 @@ jobs:
39
39
git config --global core.autocrlf false
40
40
git config --global core.eol lf
41
41
- name : Checkout repository
42
- uses : actions/checkout@v2
42
+ uses : actions/checkout@v3
43
43
- name : Check if Node.js project and has package.json
44
44
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
46
46
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
47
51
- if : steps.packagejson.outputs.exists == 'true'
48
52
name : Setup Node.js
49
- uses : actions/setup-node@v2
53
+ uses : actions/setup-node@v3
50
54
with :
51
- node-version : 14
55
+ node-version : " ${{ steps.lockversion.outputs.version }} "
52
56
cache : ' npm'
53
57
cache-dependency-path : ' **/package-lock.json'
54
58
- if : steps.packagejson.outputs.exists == 'true'
55
59
name : Install dependencies
56
60
run : npm install
57
61
- if : steps.packagejson.outputs.exists == 'true'
58
62
name : Run test
59
- run : npm test
63
+ run : npm test --if-present
60
64
- if : failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
61
65
name : Report workflow run status to Slack
62
66
uses : 8398a7/action-slack@v3
@@ -69,26 +73,43 @@ jobs:
69
73
70
74
release :
71
75
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
73
77
runs-on : ubuntu-latest
74
78
steps :
75
79
- name : Set git to use LF # to once and for all finish neverending fight between Unix and Windows
76
80
run : |
77
81
git config --global core.autocrlf false
78
82
git config --global core.eol lf
79
83
- name : Checkout repository
80
- uses : actions/checkout@v2
84
+ uses : actions/checkout@v3
81
85
- name : Check if Node.js project and has package.json
82
86
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
84
93
- if : steps.packagejson.outputs.exists == 'true'
85
94
name : Setup Node.js
86
- uses : actions/setup-node@v1
95
+ uses : actions/setup-node@v3
87
96
with :
88
- node-version : 14
97
+ node-version : " ${{ steps.lockversion.outputs.version }}"
98
+ cache : ' npm'
99
+ cache-dependency-path : ' **/package-lock.json'
89
100
- if : steps.packagejson.outputs.exists == 'true'
90
101
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 [email protected]
92
113
- if : steps.packagejson.outputs.exists == 'true'
93
114
name : Publish to any of NPM, Github, and Docker Hub
94
115
id : release
@@ -101,7 +122,7 @@ jobs:
101
122
GIT_AUTHOR_EMAIL :
[email protected]
102
123
GIT_COMMITTER_NAME : asyncapi-bot
103
124
GIT_COMMITTER_EMAIL :
[email protected]
104
- run : npm run release
125
+ run : npx semantic- release@19.0.4
105
126
- if : failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
106
127
name : Report workflow run status to Slack
107
128
uses : 8398a7/action-slack@v3
@@ -110,4 +131,4 @@ jobs:
110
131
fields : repo,action,workflow
111
132
text : ' Release workflow failed in release job'
112
133
env :
113
- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
134
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
0 commit comments