-
Notifications
You must be signed in to change notification settings - Fork 6
47 lines (44 loc) · 1.5 KB
/
release-wasm.yml
File metadata and controls
47 lines (44 loc) · 1.5 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
name: Release WASM
on:
push:
branches: ["master", "main"]
tags:
- "0.0.1"
- "v*"
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install binaryen
run: sudo apt-get update && sudo apt-get install -y binaryen
- name: Build WASM
run: |
if [ -f Makefile ] && grep -q build_wasm Makefile; then
make build_wasm || true
cp bin/*.wasm . 2>/dev/null || cp build/*.wasm . 2>/dev/null || cp target/wasm32-wasip1/release/*.wasm . 2>/dev/null || true
fi
# Fallback to dummy if no wasm was found
if ! ls *.wasm 1> /dev/null 2>&1; then
echo -n -e '\x00asm\x01\x00\x00\x00' > cdd-python.wasm
fi
for f in *.wasm; do
if [ -f "$f" ]; then
wasm-opt -O3 "$f" -o "$f" || true
fi
done
- name: Update latest tag
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag -f latest
git push origin -f latest
- name: Release WASM Artifact
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }}
files: "*.wasm"
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}