Fix const correctness #763
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_LINUX: 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] }}" |