@@ -19,31 +19,30 @@ jobs:
19
19
with :
20
20
ref : ${{ github.event.inputs.tag }}
21
21
22
- - name : Match semver pattern
23
- uses : actions-ecosystem/action-regex-match@v2
24
- id : regex-match
25
- with :
26
- text : ${{ github.event.inputs.tag }}
27
- regex : ' ^v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$'
28
-
29
22
- name : Check package version
30
23
id : cpv
31
24
uses : PostHog/check-package-version@v2
32
25
26
+ - run : npm install semver
27
+
33
28
- name : Validate tag
34
29
uses : actions/github-script@v6
35
30
with :
36
31
script : |
37
- const match = `${{ steps.regex-match.outputs.match }}`;
38
- if(match === '') {
39
- core.setFailed(`Tag ${context.payload.inputs.tag} does not match semver pattern`);
40
- } else {
32
+ const semver = require('semver')
33
+
34
+ const tag = `${context.payload.inputs.tag}`;
35
+ const version = tag.substring(1);
36
+
37
+ if (semver.valid(version)) {
41
38
const isNewVersion = `${{ steps.cpv.outputs.is-new-version }}`;
42
- if(isNewVersion === 'true') {
39
+ if (isNewVersion === 'true') {
43
40
console.log(`Version ${context.payload.inputs.tag} has not been published yet`);
44
41
} else {
45
42
core.setFailed(`Version ${context.payload.inputs.tag} is already published`);
46
43
}
44
+ } else {
45
+ core.setFailed(`Tag ${context.payload.inputs.tag} does not match semver pattern`);
47
46
}
48
47
check-status :
49
48
needs : check-version
86
85
});
87
86
88
87
for (const check_run of check_runs.data.check_runs) {
89
- if (!( check_run.status === 'completed' && check_run.conclusion === 'success')) {
88
+ if (check_run.status !== 'completed' || check_run.conclusion !== 'success') {
90
89
console.log(`${check_run.name} check failed`);
91
90
core.setFailed(`Required status check ${check_run.name} did not succeed`);
92
91
}
@@ -107,19 +106,23 @@ jobs:
107
106
allowed-endpoints : >
108
107
github.com:443
109
108
hooks.slack.com:443
109
+ nodejs.org:443
110
110
prod.api.stepsecurity.io:443
111
111
registry.npmjs.org:443
112
112
113
113
- uses : actions/checkout@v3
114
114
with :
115
115
ref : ${{ github.event.inputs.tag }}
116
116
117
- - uses : actions/setup-node@v3
117
+ - uses : ljharb/actions/node/install@main
118
+ name : " nvm install lts/* && npm install"
118
119
with :
119
- node-version : " 16.x"
120
- registry-url : " https://registry.npmjs.org"
120
+ node-version : " lts/*"
121
+ env :
122
+ NPM_CONFIG_LEGACY_PEER_DEPS : true
121
123
122
- - run : npm install
124
+ - run : echo "//registry.npmjs.org/:_authToken=${{ secrets.NODE_AUTH_TOKEN }}" >> .npmrc
125
+ - run : npm publish --dry-run
123
126
124
127
- uses : step-security/wait-for-secrets@v1
125
128
id : wait-for-secrets
@@ -131,5 +134,3 @@ jobs:
131
134
description: 'OTP from authenticator app'
132
135
133
136
- run : npm publish --access public --otp ${{ steps.wait-for-secrets.outputs.OTP }}
134
- env :
135
- NODE_AUTH_TOKEN : ${{ secrets.NODE_AUTH_TOKEN }}
0 commit comments