-
Notifications
You must be signed in to change notification settings - Fork 26
71 lines (60 loc) · 1.69 KB
/
build-crate-and-npm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Build crate and npm package
on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'
jobs:
build_crate:
name: Crate & NPM
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up rusts
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: fmt
run: cargo fmt -- --files-with-diff --check
- name: clippy
run: cargo clippy
- name: tests
run: cargo test && cargo test --release
- name: build
run: cargo build --release
- name: Upload crate artifacts
uses: actions/upload-artifact@v4
with:
name: crate
path: ./target/package/*-*.crate
- name: install wasm-pack
run: cargo install wasm-pack --locked
- name: wasm-pack build and pack
run: cd wasm && wasm-pack build && wasm-pack pack
- name: Upload npm pkg artifacts
uses: actions/upload-artifact@v4
with:
name: npm-pkg
path: ./wasm/pkg/*-*.tgz
- name: publish to crates.io if tagged
if: startsWith(github.event.ref, 'refs/tags')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }}
run: |
cargo install cargo-workspaces --locked
cargo ws publish --publish-as-is
# this has not been tested, so probably needs to be debugged next time a tag is created
- name: publish to npmjs.com if tagged
if: startsWith(github.event.ref, 'refs/tags')
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.node_auth_token }}
package: wasm/pkg/package.json