forked from angelofallars/treefetch
-
Notifications
You must be signed in to change notification settings - Fork 0
253 lines (216 loc) · 10 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
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
name: Rust Build by cross and release
on:
release:
types: [created]
env:
CRATE_NAME: freshfetch
GITHUB_TOKEN: ${{ github.token }}
RUST_BACKTRACE: 1
jobs:
test:
permissions: write-all
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
# Platforms that don't work:
#
# - sparc64-unknown-linux-gnu - cannot compile openssl-sys
# - x86_64-unknown-illumos - weird error compiling openssl - "bin/sh: 1: granlib: not found"
# - x86_64-unknown-redox - linking with `cc` failed
# - wasm32 - Only features sync,macros,io-util,rt,time are supported on wasm.
# TEST:
- os_name: Linux-x86_64-musl
os: ubuntu-20.04
target: x86_64-unknown-linux-musl
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-x86_64-unknown-linux-musl.tar.gz
- os_name: Linux-x86_64-gnu
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-x86_64-unknown-linux-gnu.tar.gz
- os_name: Linux-aarch64
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-aarch64-unknown-linux-gnu.tar.gz
- os_name: Linux-arm-musleabi
os: ubuntu-20.04
target: arm-unknown-linux-musleabi
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-arm-unknown-linux-musleabi.tar.gz
- os_name: Linux-arm-gnueabihf
os: ubuntu-20.04
target: arm-unknown-linux-gnueabihf
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-arm-unknown-linux-gnueabihf.tar.gz
- os_name: armv7-unknown-linux-gnueabi
os: ubuntu-20.04
target: armv7-unknown-linux-gnueabi
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-armv7-unknown-linux-gnueabi.tar.gz
- os_name: Linux-armv7-musleabi
os: ubuntu-20.04
target: armv7-unknown-linux-musleabi
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-armv7-unknown-linux-musleabi.tar.gz
- os_name: Linux-i686-musl
os: ubuntu-20.04
target: i686-unknown-linux-musl
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-i686-unknown-linux-musl.tar.gz
skip_tests: true
- os_name: Linux-riscv64
os: ubuntu-20.04
target: riscv64gc-unknown-linux-gnu
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-riscv64gc-unknown-linux-gnu.tar.gz
- os_name: FreeBSD-x86_64
os: ubuntu-20.04
target: x86_64-unknown-freebsd
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-x86_64-unknown-freebsd.tar.gz
skip_tests: true
# - os_name: NetBSD-x86_64
# os: ubuntu-20.04
# target: x86_64-unknown-netbsd
# bin: ${{ github.event.repository.name }}
# name: ${{ github.event.repository.name }}-x86_64-unknown-netbsd.tar.gz
# skip_tests: true
# - os_name: Windows-x86_64
# os: windows-latest
# target: x86_64-pc-windows-msvc
# bin: ${{ github.event.repository.name }}.exe
# name: ${{ github.event.repository.name }}-x86_64-pc-windows-msvc.zip
# - os_name: Windows-aarch64
# os: windows-latest
# target: aarch64-pc-windows-msvc
# bin: ${{ github.event.repository.name }}.exe
# name: ${{ github.event.repository.name }}-aarch64-pc-windows-msvc.zip
# skip_tests: true
# - os_name: Windows-i686
# os: windows-latest
# target: i686-pc-windows-msvc
# bin: ${{ github.event.repository.name }}.exe
# name: ${{ github.event.repository.name }}-i686-pc-windows-msvc-i686.zip
# skip_tests: true
- os_name: macOS-x86_64
os: macos-12
target: x86_64-apple-darwin
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-macOS-x86_64-apple-darwin.tar.gz
- os_name: macOS-aarch64
os: macos-12
target: aarch64-apple-darwin
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-macOS-aarch64-apple-darwin.tar.gz
skip_tests: true
# - os_name: IOS-aarch64
# os: macos-12
# target: aarch64-apple-ios
# bin: ${{ github.event.repository.name }}
# name: ${{ github.event.repository.name }}-Apple-aarch64-apple-ios.tar.gz
# skip_tests: true
- os_name: aarch64-linux-android
os: ubuntu-22.04
target: aarch64-linux-android
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-aarch64-linux-android.tar.gz
- os_name: Android-ARMv7a
os: ubuntu-22.04
target: armv7-linux-androideabi
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-armv7-linux-androideabi.tar.gz
- os_name: Android-ARMv7
os: ubuntu-22.04
target: arm-linux-androideabi
bin: ${{ github.event.repository.name }}
name: ${{ github.event.repository.name }}-arm-linux-androideabi.tar.gz
toolchain:
- stable
steps:
- uses: actions/checkout@v3
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.name, 'musl')
- name: Install libunwind8-dev for Android
run: sudo apt-get update --yes && sudo apt-get install --yes android-libunwind-dev
if: contains(matrix.platform.target, 'aarch64-linux-android')
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--release"
strip: true
if: |
matrix.toolchain == 'stable' &&
contains(matrix.platform.target, 'aarch64-linux-android') == false &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Build binary for aarch64-linux-android
shell: bash
run: |
rustup target add aarch64-linux-android
# Adapted from https://github.com/briansmith/ring/blob/main/mk/cargo.sh
set -eux -o pipefail
OS_NAME=$(uname -s | tr A-Z a-z)
# Avoid putting the Android tools in `$PATH` because there are tools in this
# directory like `clang` that would conflict with the same-named tools that may
# be needed to compile the build script, or to compile for other targets.
if [ -n "${ANDROID_HOME-}" ]; then
# Keep the next line in sync with the corresponding line in install-build-tools.sh.
ndk_version=25.2.9519653
ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version}
fi
if [ -n "${ANDROID_NDK_ROOT-}" ]; then
android_tools=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${OS_NAME}-x86_64/bin
fi
export CC_aarch64_linux_android=$android_tools/aarch64-linux-android21-clang
export AR_aarch64_linux_android=$android_tools/llvm-ar
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$android_tools/aarch64-linux-android21-clang
cargo build --verbose --release --target=aarch64-linux-android
if: |
matrix.toolchain == 'stable' &&
contains(matrix.platform.target, 'aarch64-linux-android') &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Package as archive
shell: bash
run: |
echo running archive
cd target/${{ matrix.platform.target }}/release
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
7z a ../../../${{ matrix.platform.name }} ${{ github.event.repository.name }}.exe
else
tar czvf ../../../${{ matrix.platform.name }} ${{ github.event.repository.name }}
fi
cd -
if: |
matrix.toolchain == 'stable' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Publish release artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-${{ matrix.platform.os_name }}
path: "${{ github.event.repository.name }}-*"
if: matrix.toolchain == 'stable'
- name: Generate SHA-256
run: shasum -a 256 ${{ matrix.platform.name }}
if: |
matrix.toolchain == 'stable' &&
( startsWith( github.ref, 'refs/tags/v' ) ||
github.ref == 'refs/tags/test-release' )
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: "${{ github.event.repository.name }}-*"
body_path: Changes.md
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' )