-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (136 loc) · 5.52 KB
/
publish-libaec.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
name: Publish libaec
on:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- platform: "macos-latest" # Wasm32-emscripten
args: "--target wasm32-unknown-emscripten"
build-dir: "libaec-wasm32-unknown-emscripten"
archive: "tar"
target: "wasm32-unknown-emscripten"
- platform: "macos-latest" # macOS arm64
args: "--target aarch64-apple-darwin"
build-dir: "libaec-osx-aarch64"
archive: "tar"
target: "aarch64-apple-darwin"
- platform: "macos-latest" # IOS
args: "--target aarch64-apple-ios"
build-dir: "libaec-ios-aarch64"
archive: "tar"
target: "aarch64-apple-ios"
- platform: "macos-latest" # macOS x86-64
args: "--target x86_64-apple-darwin"
build-dir: "libaec-osx-x86-64"
archive: "tar"
target: "x86_64-apple-darwin"
- platform: "ubuntu-22.04" # Linux x86_64
args: ""
build-dir: "libaec-linux-x86-64"
archive: "tar"
target: "x86_64-unknown-linux-gnu"
- platform: "ubuntu-22.04" # riscv64
args: "--target riscv64gc-unknown-linux-gnu"
build-dir: "libaec-riscv64gc-unknown-linux-gnu"
archive: "tar"
target: "riscv64gc-unknown-linux-gnu"
- platform: "macos-latest" # Linux arm64
args: ""
build-dir: "libaec-android-aarch64"
archive: "tar"
target: "aarch64-linux-android"
android-abi: "arm64-v8a"
- platform: "windows-latest" # Windows x86_64
args: "--target x86_64-pc-windows-msvc"
build-dir: "libaec-win-x86-64"
archive: "zip"
target: "x86_64-pc-windows-msvc"
- platform: "windows-latest" # Windows arm64
args: "--target aarch64-pc-windows-msvc"
build-dir: "libaec-win-aarch64"
archive: "zip"
target: "aarch64-pc-windows-msvc"
- platform: "ubuntu-22.04" # Linux arm64
args: "--target aarch64-unknown-linux-gnu"
build-dir: "libaec-linux-aarch64"
archive: "tar"
target: "aarch64-unknown-linux-gnu"
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "true"
- name: Install Linux arm64 toolchain
run: |
sudo apt-get install g++-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-g++" >> $GITHUB_ENV
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
if: matrix.target == 'aarch64-unknown-linux-gnu'
- name: Install riscv64 toolchain
run: |
sudo apt update
sudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libc6-dev-riscv64-cross
if: matrix.target == 'riscv64gc-unknown-linux-gnu'
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25b
local-cache: true
if: matrix.target == 'aarch64-linux-android'
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
if: contains(matrix.target, 'wasm')
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
- name: Setup Cargo NDK
run: cargo install cargo-ndk
if: matrix.target == 'aarch64-linux-android'
- name: Set up build directory
run: mkdir -p ${{ matrix.build-dir }}
- name: Build libaec
run: cargo build -p libaec --release ${{ matrix.args }}
if: matrix.target != 'aarch64-linux-android'
- name: Build libaec (Android)
run: cargo ndk -t ${{ matrix.android-abi }} build --release -p libaec ${{ matrix.args }}
if: matrix.target == 'aarch64-linux-android'
- name: Copy files
run: |
# Headers
cp crates/libaec/libaec.h "${{ matrix.build-dir }}/"
# Unix
cp -f "target/${{ matrix.target }}/release/libaec.a" "${{ matrix.build-dir }}/" || :
cp -f "target/${{ matrix.target }}/release/libaec.so" "${{ matrix.build-dir }}/" || :
cp -f "target/${{ matrix.target }}/release/libaec.dylib" "${{ matrix.build-dir }}/" || :
# Linux?
cp -f "target/release/libaec.a" "${{ matrix.build-dir }}/" || :
cp -f "target/release/libaec.so" "${{ matrix.build-dir }}/" || :
# Windows
cp -f "target/${{ matrix.target }}/release/aec.lib" "${{ matrix.build-dir }}/" || :
cp -f "target/${{ matrix.target }}/release/aec.dll" "${{ matrix.build-dir }}/" || :
shell: bash
- name: Create archive
run: |
if [[ "${{ matrix.archive }}" == "tar" ]]; then
tar -czvf ${{ matrix.build-dir }}.tar.gz ${{ matrix.build-dir }}
elif [[ "${{ matrix.archive }}" == "zip" ]]; then
7z a ${{ matrix.build-dir }}.zip ${{ matrix.build-dir }}
fi
shell: bash
- name: Uplaod to releases
run: |
latestTag=$(gh release view --json tagName --jq '.tagName')
gh release upload $latestTag ${{ matrix.build-dir }}.* --clobber
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
shell: bash