-
Notifications
You must be signed in to change notification settings - Fork 3
163 lines (154 loc) · 4.05 KB
/
rust.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Rust
on:
push:
branches: [main]
tags:
- 'v*'
- 'cli-v*'
- 'wasm-v*'
pull_request:
branches: [main]
jobs:
build-library:
runs-on: ubuntu-latest
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/cli-v')
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Check Formatting
run: cargo fmt -- --check
- name: Security audit
run: cargo audit
- name: Build Library
run: cargo build --verbose
- name: Run Library Tests
run: cargo test --verbose
- name: Run Library Tests with plaintext before with enabled
run: cargo test --verbose -F plaintext-before-extension
- name: Lint with Clippy
run: |
rustup component add clippy
cargo clippy -- -D warnings
build-cli:
runs-on: ubuntu-latest
needs: build-library
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build CLI
run: |
cd cli/src
cargo build --verbose
- name: Run CLI Tests
run: |
cd cli/src
cargo test --verbose
- name: Lint CLI with Clippy
run: |
rustup component add clippy
cd cli/src
cargo clippy -- -D warnings
build-wasm:
runs-on: ubuntu-latest
needs: build-library
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build WASM
run: |
cd wasm
cargo build --verbose
- name: Run CLI Tests
run: |
cd wasm
cargo test --verbose
- name: Lint CLI with Clippy
run: |
rustup component add clippy
cd wasm
cargo clippy -- -D warnings
publish-library:
needs: build-library
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Publish Library to crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATESTOKEN }}
publish-cli:
needs: build-cli
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/cli-v')
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Publish CLI to crates.io
run: |
cd cli/src
cargo publish --token ${{ secrets.CRATESTOKEN }}
publish-wasm:
needs: build-wasm
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
if: startsWith(github.ref, 'refs/tags/wasm-v')
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build wasm package
run: |
cd wasm
wasm-pack build --target bundler
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
token: ${{ secrets.NPM_TOKEN }}
- name: Install npm dependencies
run: |
cd wasm/pkg
npm install
npm ci
- name: Publish to npm
run: |
cd wasm/pkg
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}