-
Notifications
You must be signed in to change notification settings - Fork 0
214 lines (189 loc) · 7.09 KB
/
Copy pathrelease.yml
File metadata and controls
214 lines (189 loc) · 7.09 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Release
on:
push:
branches: [main]
paths:
- "wasm/**"
- "src/**"
- "Cargo.toml"
pull_request:
branches: [main]
paths:
- "wasm/**"
- "src/**"
- "Cargo.toml"
# Restrict default permissions; only the release job gets write access.
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Dwarnings
WASM_PACK_VERSION: "0.13.1"
jobs:
check:
name: WASM Compile Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- run: cargo check -p audex-wasm --target wasm32-unknown-unknown
check-core:
name: Core WASM Compile Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- run: cargo check -p audex --target wasm32-unknown-unknown --features serde
clippy:
name: WASM Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
components: clippy
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- run: cargo clippy -p audex-wasm --target wasm32-unknown-unknown -- -D warnings
test-native:
name: WASM Crate Unit Tests (native)
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- run: cargo test -p audex-wasm
test-wasm:
name: WASM Browser Tests
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- name: Install wasm-pack
run: cargo install wasm-pack --version "$WASM_PACK_VERSION" --locked
- name: Run wasm-bindgen-test in headless Chrome
working-directory: wasm
run: wasm-pack test --headless --chrome
build:
name: WASM Build
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [check, check-core, clippy, test-native, test-wasm]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9 # stable
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
- name: Install wasm-pack
run: cargo install wasm-pack --version "$WASM_PACK_VERSION" --locked
- name: Build (web target)
working-directory: wasm
run: wasm-pack build --target web --release
- name: Build (nodejs target)
working-directory: wasm
run: wasm-pack build --target nodejs --release --out-dir pkg-node
- name: Package web build
run: tar -czf audex-wasm-web.tar.gz -C wasm/pkg .
- name: Package node build
run: tar -czf audex-wasm-node.tar.gz -C wasm/pkg-node .
- name: Upload web artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: audex-wasm-web
path: audex-wasm-web.tar.gz
retention-days: 30
- name: Upload node artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: audex-wasm-node
path: audex-wasm-node.tar.gz
retention-days: 30
check-version:
name: Check for new version
runs-on: ubuntu-latest
if: github.event_name == 'push'
outputs:
version: ${{ steps.version.outputs.version }}
new_release: ${{ steps.tag.outputs.new_release }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check if tag already exists
id: tag
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "new_release=false" >> "$GITHUB_OUTPUT"
else
echo "new_release=true" >> "$GITHUB_OUTPUT"
fi
release:
name: GitHub Release
runs-on: ubuntu-latest
needs: [check-version, build]
if: needs.check-version.outputs.new_release == 'true'
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Extract changelog
id: changelog
env:
VERSION: ${{ needs.check-version.outputs.version }}
run: |
TITLE=$(awk "/^# ${VERSION//./\\.} /{print; exit}" CHANGELOG.md)
TITLE="${TITLE#\# }"
BODY=$(awk "/^# ${VERSION//./\\.} /{found=1; next} /^# /{if(found) exit} found{print}" CHANGELOG.md)
echo "title=${TITLE}" >> "$GITHUB_OUTPUT"
{
echo "body<<CHANGELOG_EOF"
echo "$BODY"
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create tag
env:
VERSION: ${{ needs.check-version.outputs.version }}
run: |
git tag "v${VERSION}"
git push origin "v${VERSION}"
- name: Download web artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: audex-wasm-web
- name: Download node artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: audex-wasm-node
- name: Create GitHub Release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
with:
tag_name: v${{ needs.check-version.outputs.version }}
name: ${{ steps.changelog.outputs.title }}
body: ${{ steps.changelog.outputs.body }}
files: |
audex-wasm-web.tar.gz
audex-wasm-node.tar.gz