-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (115 loc) · 4.14 KB
/
rust.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
name: Build
permissions: {}
on:
pull_request:
push:
branches:
- main
env:
CARGO_INCREMENTAL: 0
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
run: rustup update
- name: Build for Desktop Platforms
run: cargo build --release
- name: Clean up target directory (Windows only)
if: runner.os == 'Windows'
run: |
Remove-Item -Path "target\release\build" -Recurse -Force
Remove-Item -Path "target\release\deps" -Recurse -Force
Remove-Item -Path "target\release\examples" -Recurse -Force
Remove-Item -Path "target\release\incremental" -Recurse -Force
Remove-Item -Path "target\CACHEDIR.TAG" -Force
Remove-Item -Path "target\.rustc_info.json" -Force
Remove-Item -Path "target\release\.fingerprint" -Recurse -Force
Remove-Item -Path "target\release\.cargo-lock" -Force
- name: Clean up target directory (macOS and Linux only)
if: runner.os != 'Windows'
run: |
rm -rf target/release/build
rm -rf target/release/deps
rm -rf target/release/examples
rm -rf target/release/incremental
rm -f target/CACHEDIR.TAG
rm -f target/.rustc_info.json
rm -rf target/release/.fingerprint
rm -f target/release/.cargo-lock
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.os }}
path: target/
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
run: rustup update
- name: Install Android NDK
run: |
sudo apt-get update
sudo apt-get install -y wget unzip
wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip -O ndk.zip
unzip ndk.zip -d $HOME
echo "ANDROID_NDK_HOME=$HOME/android-ndk-r23b" >> $GITHUB_ENV
echo "$HOME/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH
- name: Add Android target
run: rustup target add aarch64-linux-android
- name: Build for Android
run: |
cargo install cross --git https://github.com/cross-rs/cross
cross build --release --target aarch64-linux-android
- name: Clean up target directory (Android)
run: |
rm -rf target/release/build
rm -rf target/release/deps
rm -rf target/release/examples
rm -rf target/release/incremental
rm -f target/CACHEDIR.TAG
rm -f target/.rustc_info.json
rm -rf target/release/.fingerprint
rm -f target/release/.cargo-lock
rm -f target/aarch64-linux-android/CACHEDIR.TAG
rm -rf target/aarch64-linux-android/release/build
rm -rf target/aarch64-linux-android/release/deps
rm -rf target/aarch64-linux-android/release/.fingerprint
rm -f target/aarch64-linux-android/release/.cargo-lock
- name: Upload Artifact for Android
uses: actions/upload-artifact@v4
with:
name: build-android
path: target/
build-ios:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
run: rustup update
- name: Add iOS target
run: rustup target add aarch64-apple-ios
- name: Build for iOS
run: cargo build --release --target aarch64-apple-ios
- name: Clean up target directory (iOS)
run: |
rm -rf target/aarch64-apple-ios/release/build
rm -rf target/aarch64-apple-ios/release/deps
rm -rf target/release/examples
rm -rf target/release/incremental
rm -f target/aarch64-apple-ios/CACHEDIR.TAG
rm -f target/CACHEDIR.TAG
rm -f target/.rustc_info.json
rm -rf target/aarch64-apple-ios/release/.fingerprint
rm -f target/aarch64-apple-ios/release/.cargo-lock
rm -rf target/release
- name: Upload Artifact for iOS
uses: actions/upload-artifact@v4
with:
name: build-ios
path: target/