-
-
Notifications
You must be signed in to change notification settings - Fork 176
247 lines (240 loc) · 10.9 KB
/
rust-build.yaml
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
name: Building Rust Binding And Upload Artifacts
on: workflow_call
jobs:
build:
name: Build and Upload Artifacts - ${{ matrix.settings.abi }}
runs-on: ${{ matrix.settings.os }}
strategy:
fail-fast: false
matrix:
settings:
- os: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
abi: linux-x64-gnu
build: >-
set -e &&
unset CC_x86_64_unknown_linux_gnu &&
unset CC &&
cd packages/core &&
npm run build:rs:publish -- --target x86_64-unknown-linux-gnu &&
cd ../create-farm &&
npm run build -- --target x86_64-unknown-linux-gnu &&
cd ../../rust-plugins/react && npm run build -- --target x86_64-unknown-linux-gnu --abi linux-x64-gnu &&
cd ../replace-dirname && npm run build -- --target x86_64-unknown-linux-gnu --abi linux-x64-gnu &&
apt install -y protobuf-compiler &&
cd ../sass && npm run build -- --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
- os: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
abi: linux-x64-musl
build: >-
set -e &&
unset CC_x86_64_unknown_linux_musl &&
unset CC &&
cd packages/core &&
npm run build:rs:publish -- --target x86_64-unknown-linux-musl &&
cd ../create-farm &&
npm run build -- --target x86_64-unknown-linux-musl &&
cd ../../rust-plugins/react && npm run build -- --target x86_64-unknown-linux-musl --abi linux-x64-musl &&
cd ../replace-dirname && npm run build -- --target x86_64-unknown-linux-musl --abi linux-x64-musl &&
apk add protobuf &&
cd ../sass && npm run build -- --target x86_64-unknown-linux-musl --abi linux-x64-musl
- os: windows-latest
abi: win32-x64-msvc
target: x86_64-pc-windows-msvc
- os: macos-13
abi: darwin-x64
target: x86_64-apple-darwin
- os: macos-latest
abi: darwin-arm64
target: aarch64-apple-darwin
# cross compile
# windows. Note swc plugins is not supported on ia32 and arm64
- os: windows-latest
abi: win32-ia32-msvc
target: i686-pc-windows-msvc
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
cd packages/core && npm run build:rs -- --target i686-pc-windows-msvc --cargo-flags="--no-default-features"
cd ../create-farm && npm run build -- --target i686-pc-windows-msvc
cd ../../rust-plugins/react && npm run build -- --target i686-pc-windows-msvc --abi win32-ia32-msvc
cd ../replace-dirname && npm run build -- --target i686-pc-windows-msvc --abi win32-ia32-msvc
cd ../sass && npm run build -- --target i686-pc-windows-msvc --abi win32-ia32-msvc
- os: windows-latest
abi: win32-arm64-msvc
target: aarch64-pc-windows-msvc
build: |
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
cd packages/core && npm run build:rs -- --target aarch64-pc-windows-msvc --cargo-flags="--no-default-features"
cd ../create-farm && npm run build -- --target aarch64-pc-windows-msvc
cd ../../rust-plugins/react && npm run build -- --target aarch64-pc-windows-msvc --abi win32-arm64-msvc
cd ../replace-dirname && npm run build -- --target aarch64-pc-windows-msvc --abi win32-arm64-msvc
cd ../sass && npm run build -- --target aarch64-pc-windows-msvc --abi win32-arm64-msvc
# linux
- os: ubuntu-latest
abi: linux-arm64-musl
target: aarch64-unknown-linux-musl
zig: true
- os: ubuntu-latest
abi: linux-arm64-gnu
target: aarch64-unknown-linux-gnu
zig: true
# Build for Create Farm CLI only
- os: ubuntu-latest
abi: android-arm-eabi
target: armv7-linux-androideabi
build: pnpm --filter create-farm build --target armv7-linux-androideabi
cli_only: true
zig: false
- os: ubuntu-latest
abi: linux-arm-gnueabihf
target: armv7-unknown-linux-gnueabihf
build: >-
sudo apt-get update && sudo apt-get install gcc-arm-linux-gnueabihf -y &&
pnpm --filter create-farm build --target armv7-unknown-linux-gnueabihf --zig
cli_only: true
zig: true
- os: ubuntu-latest
abi: android-arm64
target: aarch64-linux-android
build: pnpm --filter create-farm build --target aarch64-linux-android
cli_only: true
zig: false
steps:
- uses: actions/checkout@v4
- name: Cache rust artifacts
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.1.0
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Install Dependencies
run: pnpm i --frozen-lockfile
- name: Build Plugin Tools
run: pnpm --filter @farmfe/plugin-tools run build
- run: rustup target add ${{ matrix.settings.target }}
if: ${{ matrix.settings.target }}
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Use the v1 of this action
- uses: mbround18/setup-osxcross@v1
if: ${{ matrix.settings.osxcross }}
# This builds executables & sets env variables for rust to consume.
with:
osx-version: "12.3"
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.zig }}
with:
version: '0.13.0'
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
run: ${{ matrix.settings.build }}
- name: Default Build
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
run: >-
cd packages/core && npm run build:rs:publish -- ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }} &&
cd ../create-farm && npm run build -- ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }} &&
cd ../../rust-plugins/react && npm run build -- ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }} --abi ${{ matrix.settings.abi }} &&
cd ../replace-dirname && npm run build -- ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }} --abi ${{ matrix.settings.abi }} &&
cd ../sass && npm run build -- ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }} --abi ${{ matrix.settings.abi }}
shell: bash
- name: Build
if: ${{ !matrix.settings.docker && matrix.settings.build }}
run: ${{ matrix.settings.build }}
shell: bash
- name: LS Create Farm Rust
if: ${{ matrix.settings.cli_only }}
run: ls -la ./packages/create-farm/
- name: Upload Core
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding/farm.${{ matrix.settings.abi }}.node
- name: Upload Create Farm Rust
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-create-farm
path: ./packages/create-farm/create-farm.${{ matrix.settings.abi }}.node
- name: Upload Plugin React
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-react
path: rust-plugins/react/npm/${{ matrix.settings.abi }}/index.farm
- name: Upload Plugin Replace Dirname
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-replace-dirname
path: rust-plugins/replace-dirname/npm/${{ matrix.settings.abi }}/index.farm
- name: Upload Plugin Sass
if: ${{ !matrix.settings.cli_only }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-sass
path: rust-plugins/sass/npm/${{ matrix.settings.abi }}/index.farm
# Now for create-farm cli only builds
build-freebsd:
name: Build and Upload Artifacts - x86_64-unknown-freebsd
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
id: build
uses: cross-platform-actions/action@v0.25.0
env:
DEBUG: napi:*
RUSTUP_IO_THREADS: 1
with:
operating_system: freebsd
version: '14.0'
memory: 8G
cpu_count: 3
environment_variables: DEBUG RUSTUP_IO_THREADS
shell: bash
run: |
sudo pkg install -y -f curl node libnghttp2 npm
sudo npm install -g pnpm
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain beta
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ pnpm --version ~~~~"
pnpm --version
pwd
ls -lah
whoami
env
freebsd-version
echo "~~~~ Install dependencies ~~~~"
cd packages/create-farm && pnpm i --no-frozen-lockfile --ignore-scripts
echo "~~~~ Build ~~~~"
pnpm build --target x86_64-unknown-freebsd
echo "~~~~ ls -lah ~~~~"
ls -lah
rm -rf node_modules
rm -rf target
- name: Upload Create Farm Rust
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}-freebsd-x64-create-farm
path: ./packages/create-farm/create-farm.freebsd-x64.node