Audio Matrix #43
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: Audio Matrix | |
on: | |
workflow_dispatch: # lets you run a build from github.com | |
# Runs the workflow on push events but only for the main branch | |
push: | |
branches: | |
- main | |
# This is needed otherwise the github.ref is not set with ref/tags/v... | |
tags: | |
- 'v*.*.*' | |
# When pushing new commits, cancel any running builds on that branch | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PROJECT_NAME: audio-matrix | |
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
BUILD_TYPE: Release | |
# Use up to 4 cpus to build | |
CMAKE_BUILD_PARALLEL_LEVEL: 4 | |
# Name of the build directory | |
BUILD_DIR: build | |
jobs: | |
cmake-build_and_ctest: | |
name: ${{ matrix.name }} | |
strategy: | |
fail-fast: false # show all errors for each platform (vs. cancel jobs on error) | |
matrix: | |
os: [macos-latest, ubuntu-latest] | |
include: | |
- os: macOS-latest | |
name: macOS | |
ccache: ccache | |
- name: Linux | |
os: ubuntu-latest | |
ccache: ccache | |
# - os: windows-latest | |
# name: Windows | |
# ccache: sccache | |
runs-on: ${{ matrix.os }} | |
steps: | |
#A simple printout of the matrix | |
- name: printout | |
shell: bash | |
run: | | |
echo ${{ github.ref }} | |
echo "matrix.name=${{ matrix.name }}"; | |
echo "matrix.os=${{ matrix.os }}"; | |
echo "matrix.ccache=${{ matrix.ccache }}"; | |
# We need the osxutils to get the codesign and notorization tools | |
# We need to install ccache here for Windows to grab the right version | |
- name: install deps | |
shell: bash | |
run: | | |
if [ "${{ matrix.name }}" == "macOS" ]; then | |
brew install osxutils jack liblo | |
echo "brew prefix: $(brew --prefix)" | |
elif [ "${{ matrix.name }}" == "Linux" ]; then | |
sudo apt-get update && sudo apt install jackd2 libjack-jackd2-dev liblo-dev | |
# elif [ "${{ matrix.name }}" == "Windows" ]; then | |
# choco install ccache | |
else | |
echo "Unknown OS"; | |
fi; | |
# With this we checkout to our repo | |
- name: get repo and submodules | |
uses: actions/checkout@v4 | |
# Here we get the submodules like juce | |
with: | |
submodules: true | |
# Using the ccache action to store the build cache and speed up the next builds | |
- name: ccache | |
uses: hendrikmuhs/ccache-action@main | |
with: | |
key: v4-${{ matrix.os }}-${{ env.BUILD_TYPE }} | |
variant: ${{ matrix.ccache }} | |
# Typical cmake configuration with default generator | |
# With DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" we can build universal binaries for apple computers | |
- name: cmake configure | |
shell: bash | |
run: | | |
if [ "${{ matrix.name }}" == "macOS" ]; then | |
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DBUILD_TESTS=ON | |
# elif [ "${{ matrix.name }}" == "Windows" ]; then | |
# cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache }} -DBUILD_TESTS=ON | |
elif [ "${{ matrix.name }}" == "Linux" ]; then | |
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.ccache }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.ccache }} -DBUILD_TESTS=ON | |
else | |
echo "Unknown OS"; | |
fi; | |
# Build the project | |
- name: cmake build | |
shell: bash | |
run: cmake --build build --config ${{ env.BUILD_TYPE }} --parallel ${{ env.CMAKE_BUILD_PARALLEL_LEVEL }} | |
# Test the project | |
- name: ctest | |
working-directory: ${{github.workspace}}/build/test | |
run: ctest -VV | |
# Declaring the product name and the packaging directory | |
- name: declare artefact variables | |
shell: bash | |
run: | | |
echo "PACKAGE_DIR=artefacts/${{ env.PROJECT_NAME }}-${{ matrix.name}}" >> $GITHUB_ENV | |
echo "PRODUCT_NAME=${{ env.PROJECT_NAME }}-${{ matrix.name }}" >> $GITHUB_ENV | |
# Moving the artefacts to a packaging directory | |
- name: move artefacts | |
shell: bash | |
run: | | |
mkdir -p ${{ env.PACKAGE_DIR }} | |
mv "${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}" ${{ env.PACKAGE_DIR }}; | |
# We need to import the apple developer certificate so that we can codesign our binaries | |
- name: import certificates (macOS) | |
uses: apple-actions/import-codesign-certs@v2 | |
if: ${{ matrix.name == 'macOS' }} | |
with: | |
# GitHub encrypted secrets | |
p12-file-base64: ${{ secrets.DEV_ID_APP_CERT }} | |
p12-password: ${{ secrets.DEV_ID_APP_PWD }} | |
# Codesigning all the binaries | |
- name: codesign (macOS) | |
if: ${{ matrix.name == 'macOS' }} | |
run: | | |
codesign --force -s "${{ secrets.DEV_ID_APP }}" -v "${{ env.PACKAGE_DIR }}/${{ env.PROJECT_NAME }}" --deep --strict --options=runtime --timestamp; | |
# The standalone needs to have specific entitlements, which we need to add when we codesign the files. Since we have set the entitlements in the CMakeLists.txt we can use the generated file in the location below | |
# codesign --entitlements "${{ env.BUILD_DIR }}/${PLUGINS[$index]}/${PLUGINS[$index]}_artefacts/JuceLibraryCode/${PLUGINS[$index]}_Standalone.entitlements" --force -s "${{ secrets.DEV_ID_APP}}" -v "${{ env.PACKAGE_DIR }}/${PLUGIN_RELEASE_NAMES[$index]}.app" --deep --strict --options=runtime --timestamp; | |
# Here we check the code signitures | |
codesign -dv --verbose=4 "${{ env.PACKAGE_DIR }}/${{ env.PROJECT_NAME }}"; | |
# Zip the artefact | |
- name: zip artefacts | |
working-directory: ${{github.workspace}}/artefacts | |
shell: bash | |
run: | | |
if [ "${{ matrix.name }}" == "macOS" ]; then | |
zip -vr ${{ env.PRODUCT_NAME }}.zip ${{ env.PRODUCT_NAME }}/ -x "*.DS_Store" | |
# elif [ "${{ matrix.name }}" == "Windows" ]; then | |
# tar -a -c -f ${{ env.PRODUCT_NAME }}.zip ${{ env.PRODUCT_NAME }}/ | |
elif [ "${{ matrix.name }}" == "Linux" ]; then | |
zip -r ${{ env.PRODUCT_NAME }}.zip ${{ env.PRODUCT_NAME }}/ | |
else | |
echo "Unknown OS"; | |
fi; | |
# Let's now notarize the zip file and with it all its contents / binaries | |
- name: notarize (macOS) | |
working-directory: ${{github.workspace}}/artefacts | |
if: ${{ matrix.name == 'macOS' }} | |
run: | | |
# In contrast to dmg files zip files do not need to be codesigned before notarization | |
xcrun notarytool submit ${{ env.PRODUCT_NAME }}.zip --apple-id ${{ secrets.APPLE_DEV_ID }} --password ${{ secrets.APPLE_DEV_PWD }} --team-id ${{ secrets.TEAM_ID }} --wait | |
# Then we need to unzip it and staple the ticket for the gatekeeper to all binaries | |
# Since we have no app file or vst3 file we can not staple the ticket on the excutable | |
# This is only a problem when the user has no internet connection | |
- name: upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PRODUCT_NAME }}.zip | |
path: artefacts/${{ env.PRODUCT_NAME }}.zip | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: cmake-build_and_ctest | |
steps: | |
- name: Get Artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
*/*.zip |