-
Notifications
You must be signed in to change notification settings - Fork 9
264 lines (219 loc) · 9.66 KB
/
main.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
257
258
259
260
261
262
263
264
name: CI
on:
push:
branches: [ main ]
tags: [ "*" ]
pull_request:
branches: [ main ]
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- if: startsWith(github.ref, 'refs/tags/v')
uses: actions/checkout@v3
- if: startsWith(github.ref, 'refs/tags/v')
name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create ${{ github.ref_name }}
rust:
runs-on: ${{ matrix.target[0] }}
needs: create-release
strategy:
fail-fast: false
matrix:
target: # [ os, rust-target, library-file-name, library-file-extension ]
- [ macos-latest, x86_64-apple-darwin, libximu3, a ]
- [ macos-latest, aarch64-apple-darwin, libximu3, a ]
- [ ubuntu-latest, i686-unknown-linux-gnu, libximu3, a ]
- [ ubuntu-latest, aarch64-unknown-linux-gnu, libximu3, a ]
- [ ubuntu-latest, x86_64-unknown-linux-gnu, libximu3, a ]
- [ windows-latest, x86_64-pc-windows-gnu, libximu3, a ]
- [ windows-latest, x86_64-pc-windows-msvc, ximu3, lib ]
steps:
- uses: actions/checkout@v3
- if: matrix.target[0] == 'ubuntu-latest'
name: Install ubuntu dependency
run: sudo apt-get install -y libudev-dev
- name: Build
working-directory: x-IMU3-API/Rust/
env:
PKG_CONFIG_SYSROOT_DIR: /
run: |
rustup target add ${{ matrix.target[1] }}
cargo build --release --target ${{ matrix.target[1] }}
- uses: actions/upload-artifact@v3
name: Upload to artifacts
with:
name: rust-${{ matrix.target[1] }}
path: x-IMU3-API/Rust/target/${{ matrix.target[1] }}/release/${{ matrix.target[2] }}.${{ matrix.target[3] }}
- if: startsWith(github.ref, 'refs/tags/v')
name: Zip
uses: vimtor/action-zip@v1.1
with:
files: x-IMU3-API/Rust/target/${{ matrix.target[1] }}/release/${{ matrix.target[2] }}.${{ matrix.target[3] }}
dest: x-IMU3-API/Rust/target/${{ matrix.target[1] }}/release/${{ matrix.target[2] }}-${{ matrix.target[1] }}.zip
- if: startsWith(github.ref, 'refs/tags/v')
name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} "x-IMU3-API/Rust/target/${{ matrix.target[1] }}/release/${{ matrix.target[2] }}-${{ matrix.target[1] }}.zip"
rust-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Dry run
working-directory: x-IMU3-API/Rust/
run: cargo publish --no-verify --dry-run
- if: startsWith(github.ref, 'refs/tags/v')
name: Publish crate
working-directory: x-IMU3-API/Rust/
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.RUST_TOKEN }}
run: cargo publish --no-verify
c-sharp:
runs-on: windows-latest
needs: [ create-release, rust ]
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Download from artifacts
uses: actions/download-artifact@v3
with:
name: rust-x86_64-pc-windows-msvc
path: x-IMU3-API/Rust/target/release
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Run examples
working-directory: Examples/CSharp/x-IMU3-Examples/
run: msbuild x-IMU3-Examples.sln -property:Configuration=Release
python:
runs-on: ${{ matrix.target[0] }}
needs: rust
strategy:
fail-fast: false
matrix:
target: # [ os, rust-target, cibuildwheel-platform ]
- [ macos-latest, x86_64-apple-darwin, macosx_x86_64 ]
- [ macos-latest, aarch64-apple-darwin, macosx_arm64 ]
- [ ubuntu-latest, i686-unknown-linux-gnu, manylinux_i686 ]
- [ ubuntu-latest, aarch64-unknown-linux-gnu, manylinux_aarch64 ]
- [ ubuntu-latest, x86_64-unknown-linux-gnu, manylinux_x86_64 ]
- [ windows-latest, x86_64-pc-windows-msvc, win_amd64 ]
python-version: [ "cp38-", "cp39-", "cp310-", "cp311-" ]
steps:
- uses: actions/checkout@v3
- name: Download from artifacts
uses: actions/download-artifact@v3
with:
name: rust-${{ matrix.target[1] }}
path: x-IMU3-API/Rust/target/release
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U urllib3 requests
python -m pip install twine
- if: matrix.target[0] == 'ubuntu-latest'
name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheel
uses: pypa/cibuildwheel@v2.12.3
env:
CIBW_ARCHS: all
CIBW_BUILD: ${{ matrix.python-version }}${{ matrix.target[2] }}
CIBW_BEFORE_BUILD: pip install numpy
CIBW_BEFORE_BUILD_LINUX: pip install numpy && yum install -y libudev-devel
- if: startsWith(github.ref, 'refs/tags/v')
name: Publish Python package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYTHON_TOKEN }}
run: python -m twine upload --verbose --repository pypi wheelhouse/* --skip-existing
gui:
runs-on: ${{ matrix.target[0] }}
needs: [ create-release, rust ]
strategy:
fail-fast: false
matrix:
target: # [ os, rust-target, cmake-osx-architecture, gui-extension ]
- [ macos-latest, x86_64-apple-darwin, x86_64, "-Intel.dmg" ]
- [ macos-latest, aarch64-apple-darwin, arm64, "-Apple-Silicon.dmg" ]
- [ ubuntu-latest, x86_64-unknown-linux-gnu, "", "" ]
- [ windows-latest, x86_64-pc-windows-msvc, "", "-Setup.exe" ]
steps:
- uses: actions/checkout@v3
- if: matrix.target[0] == 'macos-latest'
name: Install Apple certificate # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development#add-a-step-to-your-workflow
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
KEYCHAIN_PASSWORD: ""
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Download from artifacts
uses: actions/download-artifact@v3
with:
name: rust-${{ matrix.target[1] }}
path: x-IMU3-API/Rust/target/release
- if: matrix.target[0] == 'ubuntu-latest'
name: Install ubuntu dependencies # https://github.com/juce-framework/JUCE/blob/master/docs/Linux%20Dependencies.md
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev libjack-jackd2-dev \
ladspa-sdk \
libcurl4-openssl-dev \
libfreetype6-dev \
libx11-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev \
libwebkit2gtk-4.0-dev \
libglu1-mesa-dev mesa-common-dev \
libudev-dev \
- name: Build CMake targets
run: |
mkdir cmake-build-release
cd cmake-build-release
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target[2] }}
cmake --build . --config Release
- if: matrix.target[0] == 'macos-latest'
name: Sign and notarize for macOS
working-directory: cmake-build-release/x-IMU3-GUI/x-IMU3-GUI_artefacts/Release/
run: |
codesign --options runtime --timestamp --sign 29X883CFTW "x-IMU3 GUI.app"
brew install create-dmg
create-dmg \
--volname "x-IMU3-GUI${{ matrix.target[3] }}" \
--background "../../../../installer_background.png" \
--window-pos 200 120 \
--window-size 600 320 \
--icon-size 100 \
--icon "x-IMU3 GUI.app" 140 130 \
--hide-extension "x-IMU3 GUI.app" \
--app-drop-link 450 125 \
"x-IMU3-GUI${{ matrix.target[3] }}" \
"x-IMU3 GUI.app"
xcrun notarytool submit "x-IMU3-GUI${{ matrix.target[3] }}" --team-id 29X883CFTW --apple-id ${{ secrets.AC_USERNAME }} --password ${{ secrets.AC_PASSWORD }} --wait
xcrun stapler staple "x-IMU3-GUI${{ matrix.target[3] }}"
- if: matrix.target[0] == 'ubuntu-latest'
name: Rename file for Ubuntu
run: mv "cmake-build-release/x-IMU3-GUI/x-IMU3-GUI_artefacts/Release/x-IMU3 GUI${{ matrix.target[3] }}" "cmake-build-release/x-IMU3-GUI/x-IMU3-GUI_artefacts/Release/x-IMU3-GUI${{ matrix.target[3] }}"
- if: matrix.target[0] == 'windows-latest'
name: Create installer for Windows
run: '& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" WindowsInstaller.iss'
- if: startsWith(github.ref, 'refs/tags/v')
name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} "cmake-build-release/x-IMU3-GUI/x-IMU3-GUI_artefacts/Release/x-IMU3-GUI${{ matrix.target[3] }}"