-
Notifications
You must be signed in to change notification settings - Fork 4
101 lines (97 loc) · 3.38 KB
/
rust-host.yml
File metadata and controls
101 lines (97 loc) · 3.38 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
name: rust-host
on: [push, pull_request]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Set variables based on OS and architecture for just dl-wasi-sdk
run: |
if [ "${{ runner.arch }}" = "X64" ]; then
echo "WASI_ARCH=x86_64" >> $GITHUB_ENV
else
echo "WASI_ARCH=arm64" >> $GITHUB_ENV
fi
if [ "${{ runner.os }}" = "Windows" ]; then
echo "WASI_OS=windows" >> $GITHUB_ENV
else
echo "WASI_OS=linux" >> $GITHUB_ENV
fi
echo "WASI_VERSION_FULL=27.0" >> $GITHUB_ENV
echo "WASI_VERSION=27" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: cargo-bins/cargo-binstall@main
- uses: extractions/setup-just@v3
- uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Install TinyGo Compiler
run: |
if [ "${{ runner.arch }}" = "X64" ]; then
wget https://github.com/tinygo-org/tinygo/releases/download/v0.39.0/tinygo_0.39.0_amd64.deb
sudo dpkg -i tinygo_0.39.0_amd64.deb
else
wget https://github.com/tinygo-org/tinygo/releases/download/v0.39.0/tinygo_0.39.0_armhf.deb
sudo dpkg -i tinygo_0.39.0_armhf.deb
fi
export PATH=$PATH:/usr/local/bin
- name: Check TinyGo Compiler
run: tinygo version
- name: Install wkg
run: cargo binstall wkg
- name: Install cargo-component
run: cargo binstall cargo-component@0.21.1
- name: Install wasm-tools
run: cargo binstall wasm-tools@1.235.0
- name: Install wit-bindgen
run: cargo install wit-bindgen-cli@0.44.0
- name: Install wasi-sdk
run: |
mkdir c_deps
just dl-wasi-sdk
- name: Build
run: just build
- name: Test
run: just test
- name: Build plugins in release mode (for release-draft)
if: github.ref_type == 'tag'
run: just build-plugins-release
- name: Prepare wasm files (for release-draft)
if: github.ref_type == 'tag'
run: ./scripts/prepare-wasm-files.sh --mode release --target-dir ./tmp/plugins
- name: Cache wasm files (for release-draft)
if: github.ref_type == 'tag'
id: cache-wasm-files
uses: actions/cache@v4
with:
path: ./tmp/plugins
key: ${{ runner.os }}-wasm-files-${{ github.sha }}
release-draft:
if: github.ref_type == 'tag'
permissions:
contents: write
runs-on: ubuntu-latest
needs: build-and-test
env:
RELEASE_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- name: Restore cached wasm files
id: cache-wasm-files-restore
uses: actions/cache/restore@v4
with:
path: ./tmp/plugins
key: ${{ runner.os }}-wasm-files-${{ github.sha }}
- name: Create release draft if it doesn't exist
uses: topheman/create-release-if-not-exist@v1
with:
args: ${{ env.RELEASE_NAME }} --draft --generate-notes
- name: Upload wasm files to release draft
run: |
gh release upload ${{ env.RELEASE_NAME }} ./tmp/plugins/*.wasm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}