13
13
14
14
env :
15
15
PKG_NAME : didcomm
16
+ PKG_NAME_NODEJS : didcomm-node
16
17
17
18
18
19
jobs :
25
26
current_version : ${{ steps.current_version.outputs.current_version }}
26
27
release_info : ${{ steps.release_info.outputs.release_info }}
27
28
asset_crate_url : ${{ steps.release_info.outputs.asset_crate_url }}
29
+ asset_npm_pkg_bundler_url : ${{ steps.release_info.outputs.asset_npm_pkg_bundler_url }}
30
+ asset_npm_pkg_nodejs_url : ${{ steps.release_info.outputs.asset_npm_pkg_nodejs_url }}
28
31
upload_url : ${{ steps.release_info.outputs.upload_url }}
29
32
already_in_crates_io : ${{ steps.check_in_crates_io.outputs.already_in_crates_io != '' }}
33
+ already_in_npm_bundler : ${{ steps.check_in_npm.outputs.already_in_npm_bundler != '' }}
34
+ already_in_npm_nodejs : ${{ steps.check_in_npm.outputs.already_in_npm_nodejs != '' }}
30
35
31
36
steps :
32
37
- uses : actions/checkout@v2
53
58
echo "::set-output name=asset_crate_url::$asset_crate_url"
54
59
echo "$asset_crate_url"
55
60
61
+ asset_npm_pkg_bundler_url="$(echo "$release_info" \
62
+ | jq -r '.assets[] | select(.name | match("^${{ env.PKG_NAME }}-${{ steps.current_version.outputs.current_version }}\\.tgz$")) | .browser_download_url')"
63
+ echo "::set-output name=asset_npm_pkg_bundler_url::$asset_npm_pkg_bundler_url"
64
+ echo "$asset_npm_pkg_bundler_url"
65
+
66
+ asset_npm_pkg_nodejs_url="$(echo "$release_info" \
67
+ | jq -r '.assets[] | select(.name | match("^${{ env.PKG_NAME_NODEJS }}-${{ steps.current_version.outputs.current_version }}\\.tgz$")) | .browser_download_url')"
68
+ echo "::set-output name=asset_npm_pkg_nodejs_url::$asset_npm_pkg_nodejs_url"
69
+ echo "$asset_npm_pkg_nodejs_url"
70
+
56
71
upload_url="$(echo "$release_info" | jq -r '.upload_url')"
57
72
echo "::set-output name=upload_url::$upload_url"
58
73
echo "$upload_url"
67
82
echo "::set-output name=already_in_crates_io::$out"
68
83
shell : bash {0} # to opt-out of default fail-fast behavior
69
84
85
+ - name : check if already deployed to npm
86
+ id : check_in_npm
87
+ run : |
88
+ out="$(npm view ${{ env.PKG_NAME }}@${{ steps.current_version.outputs.current_version }} --json 2>/dev/null \
89
+ | jq -r '.versions | select (.!=null)')"
90
+ echo "in npm check for ${{ env.PKG_NAME }} : $out"
91
+ echo "::set-output name=already_in_npm_bundler::$out"
92
+
93
+ out="$(npm view ${{ env.PKG_NAME_NODEJS }}@${{ steps.current_version.outputs.current_version }} --json 2>/dev/null \
94
+ | jq -r '.versions | select (.!=null)')"
95
+ echo "in npm check for ${{ env.PKG_NAME_NODEJS }}: $out"
96
+ echo "::set-output name=already_in_npm_nodejs::$out"
97
+ shell : bash {0} # to opt-out of default fail-fast behavior
98
+
99
+
70
100
release :
71
101
name : Release
72
102
if : github.ref == 'refs/heads/stable'
@@ -81,20 +111,8 @@ jobs:
81
111
rustup toolchain install stable
82
112
shell : bash
83
113
84
- - name : package and verify the crate
85
- id : build_assets
86
- if : ${{ !needs.checks.outputs.asset_crate_url }}
87
- run : |
88
- cargo package
89
-
90
- # TODO
91
- # - verify that it's not more than crates.io limit (10 MB)
92
- # - explore wthere we need to upload another artifact (without extension)
93
- ls -la target/package
94
- cargo package --list
95
-
96
- asset_crate_name="$(find target/package -name '*.crate' -printf '%f')"
97
- echo "::set-output name=asset_crate_name::$asset_crate_name"
114
+ - name : Install wasm-pack
115
+ run : curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
98
116
shell : bash
99
117
100
118
- name : Create GitHub Release
@@ -109,37 +127,142 @@ jobs:
109
127
110
128
- name : Set upload url
111
129
id : upload_url
112
- if : ${{ !needs.checks.outputs.asset_crate_url }}
130
+ if : ${{ !( needs.checks.outputs.asset_crate_url && needs.checks.outputs.asset_npm_pkg_bundler_url && needs.checks.outputs.asset_npm_pkg_nodejs_url) }}
113
131
run : |
114
132
if [[ -n "${{ needs.checks.outputs.upload_url }}" ]]; then
115
133
echo "::set-output name=value::${{ needs.checks.outputs.upload_url }}"
116
134
else
117
135
echo "::set-output name=value::${{ steps.create_release.outputs.upload_url }}"
118
136
fi
119
137
120
- - name : Upload to GitHub
138
+ - name : package and verify (crate)
139
+ id : build_assets_crate
140
+ if : ${{ !needs.checks.outputs.asset_crate_url }}
141
+ run : |
142
+ cargo package
143
+
144
+ # TODO
145
+ # - verify that it's not more than crates.io limit (10 MB)
146
+ # - explore whether we need to upload another artifact (without extension)
147
+ ls -la target/package
148
+ cargo package --list
149
+
150
+ asset_name="$(find target/package -name '*.crate' -printf '%f')"
151
+ echo "::set-output name=asset_name::$asset_name"
152
+ shell : bash
153
+
154
+ - name : upload to GitHub (crate)
121
155
if : ${{ !needs.checks.outputs.asset_crate_url }}
122
156
uses : actions/upload-release-asset@v1
123
157
env :
124
158
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
125
159
with :
126
160
upload_url : ${{ steps.upload_url.outputs.value }}
127
- asset_path : target/package/${{ steps.build_assets .outputs.asset_crate_name }}
128
- asset_name : ${{ steps.build_assets .outputs.asset_crate_name }}
161
+ asset_path : target/package/${{ steps.build_assets_crate .outputs.asset_name }}
162
+ asset_name : ${{ steps.build_assets_crate .outputs.asset_name }}
129
163
asset_content_type : application/octet-stream # TODO check for less generic type
130
164
165
+ - name : package and verify (npm bundler)
166
+ id : build_assets_npm_bundler
167
+ if : ${{ !needs.checks.outputs.asset_npm_pkg_bundler_url }}
168
+ run : |
169
+ cd wasm
170
+ rm -rf pkg
171
+
172
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME }}\1~}" ./Cargo.toml
173
+ wasm-pack build --target bundler
174
+
175
+ # verify
176
+ pushd pkg
177
+ npm install .
178
+ popd
179
+
180
+ wasm-pack pack
181
+ asset_name="$(find pkg -name '*.tgz' -printf '%f')"
182
+ echo "::set-output name=asset_name::$asset_name"
183
+ shell : bash
184
+
185
+ - name : upload to GitHub (npm bundler)
186
+ if : ${{ !needs.checks.outputs.asset_npm_pkg_bundler_url }}
187
+ uses : actions/upload-release-asset@v1
188
+ env :
189
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
190
+ with :
191
+ upload_url : ${{ steps.upload_url.outputs.value }}
192
+ asset_path : wasm/pkg/${{ steps.build_assets_npm_bundler.outputs.asset_name }}
193
+ asset_name : ${{ steps.build_assets_npm_bundler.outputs.asset_name }}
194
+ asset_content_type : application/x-gtar
195
+
196
+ - name : package and verify (npm nodejs)
197
+ id : build_assets_npm_nodejs
198
+ if : ${{ !needs.checks.outputs.asset_npm_pkg_nodejs_url }}
199
+ run : |
200
+ cd wasm
201
+ rm -rf pkg
202
+
203
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME_NODEJS }}\1~}" ./Cargo.toml
204
+ wasm-pack build --target bundler
205
+
206
+ # verify
207
+ pushd pkg
208
+ npm install .
209
+ popd
210
+
211
+ wasm-pack pack
212
+ asset_name="$(find pkg -name '*.tgz' -printf '%f')"
213
+ echo "::set-output name=asset_name::$asset_name"
214
+ shell : bash
215
+
216
+ - name : upload to GitHub (npm nodejs)
217
+ if : ${{ !needs.checks.outputs.asset_npm_pkg_nodejs_url }}
218
+ uses : actions/upload-release-asset@v1
219
+ env :
220
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
221
+ with :
222
+ upload_url : ${{ steps.upload_url.outputs.value }}
223
+ asset_path : wasm/pkg/${{ steps.build_assets_npm_nodejs.outputs.asset_name }}
224
+ asset_name : ${{ steps.build_assets_npm_nodejs.outputs.asset_name }}
225
+ asset_content_type : application/x-gtar
226
+
131
227
# NOTE looks like there is no option to skip packaging here
132
228
# and use already prepared artifacts
133
- - name : Publish to crates.io
229
+
230
+ - name : publish to crates.io
134
231
if : needs.checks.outputs.already_in_crates_io == 'false'
135
232
env :
136
233
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
137
234
run : cargo publish
138
235
shell : bash
139
236
237
+ - name : publish to npm (bundler)
238
+ if : needs.checks.outputs.already_in_npm_bundler == 'false'
239
+ env :
240
+ NPM_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
241
+ run : |
242
+ cd wasm
243
+ rm -rf pkg
244
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME }}\1~}" ./Cargo.toml
245
+ wasm-pack build --target nodejs
246
+ echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >pkg/.npmrc
247
+ wasm-pack publish
248
+ shell : bash
249
+
250
+ - name : publish to npm (nodejs)
251
+ if : needs.checks.outputs.already_in_npm_nodejs == 'false'
252
+ env :
253
+ NPM_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
254
+ run : |
255
+ cd wasm
256
+ rm -rf pkg
257
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME_NODEJS }}\1~}" ./Cargo.toml
258
+ wasm-pack build --target nodejs
259
+ echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >pkg/.npmrc
260
+ wasm-pack publish
261
+ shell : bash
262
+
140
263
141
- deploy-dev-crates-io :
142
- name : Publish dev to crates.io
264
+ deploy-dev :
265
+ name : publish dev to crates.io
143
266
if : github.ref != 'refs/heads/stable' && github.event_name == 'workflow_dispatch'
144
267
runs-on : ubuntu-latest
145
268
steps :
@@ -151,21 +274,74 @@ jobs:
151
274
rustup toolchain install stable
152
275
shell : bash
153
276
277
+ - name : Install wasm-pack
278
+ run : curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
279
+ shell : bash
280
+
154
281
- name : set dev version
155
282
run : |
156
283
sed -i -r "0,/version/{s~^version = (['\"])(.+)['\"]~version = \1\2-0.dev.${{ github.event.inputs.devN }}\1~}" ./Cargo.toml
157
284
grep version ./Cargo.toml
285
+ sed -i -r "0,/version/{s~^version = (['\"])(.+)['\"]~version = \1\2-0.dev.${{ github.event.inputs.devN }}\1~}" ./wasm/Cargo.toml
286
+ grep version ./wasm/Cargo.toml
158
287
shell : bash
159
288
160
- - name : verify the package
289
+ - name : verify the package (crate)
161
290
run : |
162
291
cargo package --allow-dirty
163
292
ls -la target/package
164
293
cargo package --allow-dirty --list
165
294
shell : bash
166
295
167
- - name : publish
296
+ - name : publish to crates.io
168
297
env :
169
298
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
170
299
run : cargo publish --allow-dirty
171
300
shell : bash
301
+
302
+ - name : verify the package (npm bundler)
303
+ run : |
304
+ cd wasm
305
+ rm -rf pkg
306
+
307
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME }}\1~}" ./Cargo.toml
308
+ wasm-pack build --target bundler
309
+
310
+ # verify
311
+ pushd pkg
312
+ npm install .
313
+ popd
314
+ shell : bash
315
+
316
+ - name : publish to npm (bundler)
317
+ if : false
318
+ env :
319
+ NPM_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
320
+ run : |
321
+ cd wasm
322
+ echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >pkg/.npmrc
323
+ wasm-pack publish --tag dev
324
+ shell : bash
325
+
326
+ - name : verify the package (npm nodejs)
327
+ run : |
328
+ cd wasm
329
+ rm -rf pkg
330
+
331
+ sed -i -r "0,/name/{s~^name = (['\"]).+['\"]~name = \1${{ env.PKG_NAME_NODEJS }}\1~}" ./Cargo.toml
332
+ wasm-pack build --target nodejs
333
+
334
+ # verify
335
+ pushd pkg
336
+ npm install .
337
+ popd
338
+ shell : bash
339
+
340
+ - name : publish to npm (nodejs)
341
+ env :
342
+ NPM_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
343
+ run : |
344
+ cd wasm
345
+ echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >pkg/.npmrc
346
+ wasm-pack publish --tag dev
347
+ shell : bash
0 commit comments