@@ -2,190 +2,100 @@ name: Publish to NPM
2
2
on :
3
3
release :
4
4
types : [created]
5
- workflow_dispatch :
6
-
5
+ workflow_dispatch :
7
6
jobs :
8
7
build :
9
8
runs-on : ubuntu-latest
10
9
steps :
11
10
- name : Checkout
12
11
uses : actions/checkout@v4
13
-
14
12
- name : Setup Node
15
13
uses : actions/setup-node@v4
16
14
with :
17
15
node-version : ' 20'
18
16
registry-url : ' https://registry.npmjs.org'
19
-
20
17
- name : Install dependencies and build
21
18
run : |
22
19
npm i --package-lock-only
23
20
npm ci
24
21
npm run build --if-present
25
-
26
- - name : Print GITHUB_REF for debugging
27
- run : echo "GITHUB_REF is ${GITHUB_REF}"
28
-
29
- - name : Determine publish command
30
- id : publish_command
31
- run : |
32
- if [[ "${GITHUB_REF}" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+-rc ]]; then
33
- echo "::set-output name=command::npm publish --tag next"
34
- elif [[ "${GITHUB_REF}" =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9] ]]; then
35
- echo "::set-output name=command::npm publish"
36
- else
37
- echo "Branch or tag not supported for publishing"
38
- exit 1
39
- fi
40
-
41
- - name : Check for changes in core package
42
- id : core_changes
22
+ - name : Publish core package on NPM.js
43
23
working-directory : ./packages/core
44
24
run : |
45
- if git diff --quiet HEAD^ HEAD .; then
46
- echo "No changes in core package"
47
- echo "::set-output name=changed::false"
25
+ if npm info @open-cells/core@$(jq -r .version < package.json) > /dev/null 2>&1; then
26
+ echo "Version already published"
48
27
else
49
- echo "Changes detected in core package"
50
- echo "::set-output name=changed::true"
28
+ npm publish || echo "Publish failed"
51
29
fi
52
-
53
- - name : Publish core package on NPM.js
54
- if : steps.core_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
55
- working-directory : ./packages/core
56
- run : ${{ steps.publish_command.outputs.command }}
57
30
env :
58
31
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
59
-
60
- - name : Check for changes in core-plugin package
61
- id : core_plugin_changes
32
+ - name : Publish core-plugin package on NPM.js
62
33
working-directory : ./packages/core-plugin
63
34
run : |
64
- if git diff --quiet HEAD^ HEAD .; then
65
- echo "No changes in core-plugin package"
66
- echo "::set-output name=changed::false"
35
+ if npm info @open-cells/core-plugin@$(jq -r .version < package.json) > /dev/null 2>&1; then
36
+ echo "Version already published"
67
37
else
68
- echo "Changes detected in core-plugin package"
69
- echo "::set-output name=changed::true"
38
+ npm publish || echo "Publish failed"
70
39
fi
71
-
72
- - name : Publish core-plugin package on NPM.js
73
- if : steps.core_plugin_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
74
- working-directory : ./packages/core-plugin
75
- run : ${{ steps.publish_command.outputs.command }}
76
40
env :
77
41
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
78
-
79
- - name : Check for changes in element-controller package
80
- id : element_controller_changes
42
+ - name : Publish element-controller package on NPM.js
81
43
working-directory : ./packages/element-controller
82
44
run : |
83
- if git diff --quiet HEAD^ HEAD .; then
84
- echo "No changes in element-controller package"
85
- echo "::set-output name=changed::false"
45
+ if npm info @open-cells/element-controller@$(jq -r .version < package.json) > /dev/null 2>&1; then
46
+ echo "Version already published"
86
47
else
87
- echo "Changes detected in element-controller package"
88
- echo "::set-output name=changed::true"
48
+ npm publish || echo "Publish failed"
89
49
fi
90
-
91
- - name : Publish element-controller package on NPM.js
92
- if : steps.element_controller_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
93
- working-directory : ./packages/element-controller
94
- run : ${{ steps.publish_command.outputs.command }}
95
50
env :
96
51
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
97
-
98
- - name : Check for changes in page-controller package
99
- id : page_controller_changes
52
+ - name : Publish page-controller package on NPM.js
100
53
working-directory : ./packages/page-controller
101
54
run : |
102
- if git diff --quiet HEAD^ HEAD .; then
103
- echo "No changes in page-controller package"
104
- echo "::set-output name=changed::false"
55
+ if npm info @open-cells/page-controller@$(jq -r .version < package.json) > /dev/null 2>&1; then
56
+ echo "Version already published"
105
57
else
106
- echo "Changes detected in page-controller package"
107
- echo "::set-output name=changed::true"
58
+ npm publish || echo "Publish failed"
108
59
fi
109
-
110
- - name : Publish page-controller package on NPM.js
111
- if : steps.page_controller_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
112
- working-directory : ./packages/page-controller
113
- run : ${{ steps.publish_command.outputs.command }}
114
60
env :
115
61
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
116
-
117
- - name : Check for changes in page-mixin package
118
- id : page_mixin_changes
62
+ - name : Publish page-mixin package on NPM.js
119
63
working-directory : ./packages/page-mixin
120
64
run : |
121
- if git diff --quiet HEAD^ HEAD .; then
122
- echo "No changes in page-mixin package"
123
- echo "::set-output name=changed::false"
65
+ if npm info @open-cells/page-mixin@$(jq -r .version < package.json) > /dev/null 2>&1; then
66
+ echo "Version already published"
124
67
else
125
- echo "Changes detected in page-mixin package"
126
- echo "::set-output name=changed::true"
68
+ npm publish || echo "Publish failed"
127
69
fi
128
-
129
- - name : Publish page-mixin package on NPM.js
130
- if : steps.page_mixin_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
131
- working-directory : ./packages/page-mixin
132
- run : ${{ steps.publish_command.outputs.command }}
133
70
env :
134
71
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
135
-
136
- - name : Check for changes in page-transitions package
137
- id : page_transitions_changes
72
+ - name : Publish page-transitions package on NPM.js
138
73
working-directory : ./packages/page-transitions
139
74
run : |
140
- if git diff --quiet HEAD^ HEAD .; then
141
- echo "No changes in page-transitions package"
142
- echo "::set-output name=changed::false"
75
+ if npm info @open-cells/page-transitions@$(jq -r .version < package.json) > /dev/null 2>&1; then
76
+ echo "Version already published"
143
77
else
144
- echo "Changes detected in page-transitions package"
145
- echo "::set-output name=changed::true"
78
+ npm publish || echo "Publish failed"
146
79
fi
147
-
148
- - name : Publish page-transitions package on NPM.js
149
- if : steps.page_transitions_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
150
- working-directory : ./packages/page-transitions
151
- run : ${{ steps.publish_command.outputs.command }}
152
80
env :
153
81
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
154
-
155
- - name : Check for changes in localize package
156
- id : localize_changes
82
+ - name : Publish localize package on NPM.js
157
83
working-directory : ./packages/localize
158
84
run : |
159
- if git diff --quiet HEAD^ HEAD .; then
160
- echo "No changes in localize package"
161
- echo "::set-output name=changed::false"
85
+ if npm info @open-cells/localize@$(jq -r .version < package.json) > /dev/null 2>&1; then
86
+ echo "Version already published"
162
87
else
163
- echo "Changes detected in localize package"
164
- echo "::set-output name=changed::true"
88
+ npm publish || echo "Publish failed"
165
89
fi
166
-
167
- - name : Publish localize package on NPM.js
168
- if : steps.localize_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
169
- working-directory : ./packages/localize
170
- run : ${{ steps.publish_command.outputs.command }}
171
90
env :
172
91
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
173
-
174
- - name : Check for changes in create-app package
175
- id : create_app_changes
92
+ - name : Publish create-app package on NPM.js
176
93
working-directory : ./packages/create-app
177
94
run : |
178
- if git diff --quiet HEAD^ HEAD .; then
179
- echo "No changes in create-app package"
180
- echo "::set-output name=changed::false"
95
+ if npm info @open-cells/create-app@$(jq -r .version < package.json) > /dev/null 2>&1; then
96
+ echo "Version already published"
181
97
else
182
- echo "Changes detected in create-app package"
183
- echo "::set-output name=changed::true"
98
+ npm publish || echo "Publish failed"
184
99
fi
185
-
186
- - name : Publish create-app package on NPM.js
187
- if : steps.create_app_changes.outputs.changed == 'true' && steps.publish_command.outputs.command != ''
188
- working-directory : ./packages/create-app
189
- run : ${{ steps.publish_command.outputs.command }}
190
100
env :
191
101
NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
0 commit comments