-
Notifications
You must be signed in to change notification settings - Fork 4
180 lines (154 loc) · 6.05 KB
/
publish.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Publish
on:
workflow_dispatch:
release:
types:
- published
jobs:
compile_core:
name: Compile Core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: stable
target: wasm32-wasi
default: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Get wasm-opt
run: |
curl -L https://github.com/WebAssembly/binaryen/releases/download/version_116/binaryen-version_116-x86_64-linux.tar.gz > binaryen.tar.gz
tar xvzf binaryen.tar.gz
sudo cp binaryen-version_116/bin/wasm-opt /usr/local/bin
sudo chmod +x /usr/local/bin/wasm-opt
- name: Make core
run: make core
- name: Opt core
run: wasm-opt --enable-reference-types --enable-bulk-memory --strip -O3 lib/target/wasm32-wasi/release/core.wasm -o lib/target/wasm32-wasi/release/core.wasm
- name: Upload core binary to artifacts
uses: actions/upload-artifact@v4
with:
name: engine
path: lib/target/wasm32-wasi/release/core.wasm
- name: Upload wasi-deps
uses: actions/upload-artifact@v4
with:
name: wasi-deps
path: lib/target/wasm32-wasi/wasi-deps/
compile_cli:
name: Compile CLI
needs: compile_core
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: linux
os: ubuntu-latest
path: bin/target/x86_64-unknown-linux-gnu/release/extism-py
asset_name: extism-py-x86_64-linux-${{ github.event.release.tag_name }}
shasum_cmd: sha256sum
target: x86_64-unknown-linux-gnu
# - name: linux-arm64
# os: ubuntu-latest
# path: bin/target/aarch64-unknown-linux-gnu/release/extism-py
# asset_name: extism-py-aarch64-linux-${{ github.event.release.tag_name }}
# shasum_cmd: sha256sum
# target: aarch64-unknown-linux-gnu
- name: macos
os: macos-latest
path: bin/target/x86_64-apple-darwin/release/extism-py
asset_name: extism-py-x86_64-macos-${{ github.event.release.tag_name }}
shasum_cmd: shasum -a 256
target: x86_64-apple-darwin
- name: macos-arm64
os: macos-latest
path: bin/target/aarch64-apple-darwin/release/extism-py
asset_name: extism-py-aarch64-macos-${{ github.event.release.tag_name }}
shasum_cmd: shasum -a 256
target: aarch64-apple-darwin
# - name: windows
# os: windows-latest
# path: bin\target\x86_64-pc-windows-msvc\release\extism-py.exe
# asset_name: extism-py-x86_64-windows-${{ github.event.release.tag_name }}
# target: x86_64-pc-windows-msvc
# - name: windows-arm64
# os: windows-latest
# path: bin\target\aarch64-pc-windows-msvc\release\extism-py.exe
# asset_name: extism-py-aarch64-windows-${{ github.event.release.tag_name }}
# target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@v4
with:
name: engine
path: bin
- uses: actions/download-artifact@v4
with:
name: wasi-deps
path: wasi-deps
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: stable
target: ${{ matrix.target }}
default: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install gnu gcc
run: |
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu
sudo apt-get install gcc-aarch64-linux-gnu
if: matrix.os == 'ubuntu-latest'
- name: Build CLI ${{ matrix.os }}
env:
EXTISM_ENGINE_PATH: core.wasm
run: cd bin && cargo build --release --target ${{ matrix.target }} --package extism-py
- name: Create directory structure
run: mkdir -p extism-py/bin extism-py/share && mv wasi-deps/usr extism-py/share/extism-py && mv ${{ matrix.path }} extism-py/bin/
- name: Archive assets
run: tar czf ${{ matrix.asset_name }}.tar.gz extism-py
- name: Upload assets to artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.tar.gz
path: ${{ matrix.asset_name }}.tar.gz
- name: Upload assets to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
asset_content_type: application/gzip
- name: Generate asset hash (Linux/MacOS)
run: ${{ matrix.shasum_cmd }} ${{ matrix.asset_name }}.tar.gz | awk '{ print $1 }' > ${{ matrix.asset_name }}.tar.gz.sha256
if: runner.os != 'Windows'
- name: Generate asset hash (Windows)
run: Get-FileHash -Path ${{ matrix.asset_name }}.tar.gz -Algorithm SHA256 | Select-Object -ExpandProperty Hash > ${{ matrix.asset_name }}.tar.gz.sha256
shell: pwsh
if: runner.os == 'Windows'
- name: Upload asset hash to artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.tar.gz.sha256
path: ${{ matrix.asset_name }}.tar.gz.sha256
- name: Upload asset hash to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.asset_name }}.tar.gz.sha256
asset_name: ${{ matrix.asset_name }}.tar.gz.sha256
asset_content_type: plain/text