-
Notifications
You must be signed in to change notification settings - Fork 28
256 lines (226 loc) · 9.59 KB
/
cross-build.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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: Rust Cross Build
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
default: '7.1.0'
dryRun:
description: '测试写这个为 true'
required: true
default: 'false'
env:
CARGO_PKG_VERSION: ${{ github.event.inputs.version }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
cross-build:
name: Release - ${{ matrix.platform.os-name }}
strategy:
fail-fast: false
matrix:
platform:
- os-name: FreeBSD-x86_64
runs-on: ubuntu-20.04
target: x86_64-unknown-freebsd
- os-name: aarch64-unknown-linux-gnu
runs-on: ubuntu-20.04
target: aarch64-unknown-linux-gnu
- os-name: x86_64-unknown-linux-gnu
runs-on: ubuntu-20.04
target: x86_64-unknown-linux-gnu
# - os-name: Linux-x86_64-musl
# runs-on: ubuntu-20.04
# target: x86_64-unknown-linux-musl
# - os-name: Linux-aarch64-musl
# runs-on: ubuntu-20.04
# target: aarch64-unknown-linux-musl
- os-name: Linux-riscv64
runs-on: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu
- os-name: Linux-s390x
runs-on: ubuntu-20.04
target: s390x-unknown-linux-gnu
- os-name: Windows-x86_64-msvc
runs-on: windows-latest
target: x86_64-pc-windows-msvc
- os-name: Windows-x86_64-aarch64
runs-on: windows-latest
target: aarch64-pc-windows-msvc
- os-name: Windows-x86_64-gnu
runs-on: windows-latest
target: x86_64-pc-windows-gnu
- os-name: macOS-x86_64
runs-on: macOS-latest
target: x86_64-apple-darwin
- os-name: macOS-aarch64
runs-on: macOS-latest
target: aarch64-apple-darwin
# more targets here ...
env:
TZ: Asia/Shanghai
runs-on: ${{ matrix.platform.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Windows Environment
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
scoop install main/llvm
scoop install main/mingw
scoop install main/nodejs
${{ matrix.platform.setup }}
- name: Change Version Windows
if: ${{ runner.os == 'Windows' }}
run: |
(Get-Content -Path .\Cargo.toml -Raw) -replace '^version\s*=\s*".*?"', "version = `"${{inputs.version}}`"" |
Set-Content -Path .\Cargo.toml
shell: pwsh
- name: Change Version Linux
if: ${{ runner.os == 'Linux' }}
run: |
sed -i 's/^version = \"[^\"]*\"/version = "${{inputs.version}}"/' Cargo.toml
- name: Change Version Mac
if: ${{ runner.os == 'macOS' }}
run: |
sed -i '' 's/^version = \"[^\"]*\"/version = "${{inputs.version}}"/' Cargo.toml
- name: Setup Linux Environment
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt install -y nodejs llvm clang pkg-config libssl-dev
${{ matrix.platform.setup }}
- name: Set up Homebrew
id: set-up-homebrew
if: ${{ runner.os == 'macOS' }}
uses: Homebrew/actions/setup-homebrew@master
- name: Setup MacOS Environment
if: ${{ runner.os == 'macOS' }}
run: |
brew install llvm protobuf automake libtool
${{ matrix.platform.setup }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: BUILD PROTO & lang-unicodes
run: |
cargo build -p lang-unicodes
cargo build -p cn-font-proto
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: build
target: ${{ matrix.platform.target }}
args: '--locked --release -p ffi --no-default-features'
strip: false
env:
HARFBUZZ_SYS_NO_PKG_CONFIG: 'True'
- name: Rename Package On Mac
if: ${{ runner.os == 'macOS'}}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
mv ./libffi.dylib ./libffi-${{ matrix.platform.target }}.dylib
- name: Rename Package On Linux
if: ${{ runner.os == 'Linux'}}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
mv ./libffi.so ./libffi-${{ matrix.platform.target }}.so
- name: Rename Package on Windows
if: ${{ runner.os == 'Windows' }}
working-directory: ./target/${{ matrix.platform.target }}/release
run: |
ren ffi.dll libffi-${{ matrix.platform.target }}.dll
# 这里先不重命名,因为每个环境的架构不一样,操作繁琐
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.platform.target }}
path: ./target/${{ matrix.platform.target }}/release/libffi-${{ matrix.platform.target }}.*
if-no-files-found: error
build-wasm:
name: Release - WASM
runs-on: ubuntu-24.04
env:
TZ: Asia/Shanghai
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Environment
run: |
sudo apt update
sudo apt upgrade
sudo apt install -y llvm clang pkg-config libssl-dev protobuf-compiler
- name: Change Version Linux
run: |
sed -i 's/^version = \"[^\"]*\"/version = "${{inputs.version}}"/' Cargo.toml
- name: Setup WASI Environment
working-directory: .
run: |
sudo sh ./.devcontainer/wasi-install.sh
sudo sh ./.devcontainer/wasm-opt-install.sh
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Update Rust
run: /home/runner/.cargo/bin/rustup target add wasm32-wasip1
- name: Build
working-directory: ./packages/wasm-edge
run: |
export WASI_SYSROOT="/opt/wasi-sdk/wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot/"
export PATH=$PATH:/opt/binaryen/binaryen-version_119/bin
sh build-wasi.sh
- name: Rename Package
working-directory: .
run: |
mv ./target/wasm32-wasip1/release/wasm_edge.Oz.wasm ./target/wasm32-wasip1/release/libffi-wasm32-wasip1.wasm
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-wasm32-wasip1
path: ./target/wasm32-wasip1/release/libffi-wasm32-wasip1.wasm
if-no-files-found: error
create-release:
if: ${{ github.event.inputs.dryRun != 'true' }}
runs-on: ubuntu-latest
needs: [build-wasm, cross-build]
permissions: write-all
steps:
- name: Create Release
uses: actions/create-release@v1
id: create_release
with:
tag_name: ${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
body: |
Release ${{ github.event.inputs.version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
path: ./artifacts
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R ./artifacts
- name: prepare upload
run: |
mkdir release
- name: Release Upload Assets
uses: jaywcjlove/github-action-upload-assets@main
with:
tag: ${{github.event.inputs.version}}
asset-path: '["./artifacts/*"]'
token: ${{ secrets.GITHUB_TOKEN }}