Merge pull request #75 from JohT/renovate/cpm-cmake-cpm.cmake-0.x #198
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: Build with CMake | |
# Based on https://github.com/sudara/pamplejuce | |
on: | |
push: | |
# Ignore changes in documentation | |
paths-ignore: | |
- '**/LICENSE' | |
- '**.md' | |
- '**.svg' | |
- '**.png' | |
- '**.pdf' | |
- '**.code-workspace' | |
- '.clang-format' | |
- '.clang-tidy' | |
- '.gitignore' | |
- 'renovate.json' | |
env: | |
PROJECT_NAME: Speclet # Must match the JUCE project name from juce_add_plugin | |
BUILD_TYPE: Release | |
BUILD_DIR: Builds | |
GNU_COMPILER_VERSION: 13 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PLUGINVAL_VERSION: v1.0.4 | |
DISPLAY: :0 # linux pluginval needs this | |
# jobs are run in parallel on different machines | |
# all steps run in series | |
jobs: | |
build_and_test: | |
name: ${{ matrix.artifact }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # show all errors for each platform (vs. cancel jobs on error) | |
matrix: | |
#os: [ubuntu-latest] # first test only with linux | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
artifact: Linux | |
- os: windows-latest | |
artifact: Windows | |
- os: macos-latest | |
artifact: MacOS | |
steps: | |
- name: Install JUCE's Linux Dependencies and select g++ ${{ env.GNU_COMPILER_VERSION }} | |
if: runner.os == 'Linux' | |
# Thanks to McMartin & co https://forum.juce.com/t/list-of-juce-dependencies-under-linux/15121/44 | |
# Added further dependencies from https://github.com/Tracktion/pluginval/blob/develop/.github/workflows/build.yaml | |
run: | | |
sudo apt-get update | |
sudo apt install -y g++-${{ env.GNU_COMPILER_VERSION }} gcc-${{ env.GNU_COMPILER_VERSION }} libasound2-dev libx11-dev libxinerama-dev libxext-dev libfreetype6-dev libwebkit2gtk-4.1-dev libglu1-mesa-dev ccache xvfb | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get install -y freeglut3-dev g++ libcurl4-openssl-dev libjack-jackd2-dev libxcomposite-dev libxcursor-dev libxrandr-dev mesa-common-dev ladspa-sdk libgtk-3-dev | |
# Starting Virtual Frame Buffer X Server (Xvfb) as local display in the background | |
sudo /usr/bin/Xvfb $DISPLAY & | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GNU_COMPILER_VERSION }} ${{ env.GNU_COMPILER_VERSION }} | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ env.GNU_COMPILER_VERSION }} ${{ env.GNU_COMPILER_VERSION }} | |
# This block can be removed once 15.1 is default | |
# JUCE requires it when building on macOS 14 | |
- name: Use latest Xcode on system (macOS) | |
if: runner.os == 'macOS' | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: latest-stable | |
- name: Get latest CMake | |
uses: lukka/get-cmake@latest | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true # Gotta get JUCE populated | |
- name: ccache | |
if: matrix.os != 'windows-latest' | |
uses: hendrikmuhs/ccache-action@v1 | |
with: | |
key: ${{ matrix.os }}-${{ matrix.type }} | |
- name: Configure | |
shell: bash | |
run: cmake -B ${{ env.BUILD_DIR }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . | |
- name: Build | |
shell: bash | |
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ env.BUILD_TYPE }} | |
- name: Test | |
working-directory: ${{ env.BUILD_DIR }} | |
run: ctest | |
- name: Pluginval Linux | |
working-directory: ${{ env.BUILD_DIR }} | |
if: matrix.artifact == 'Linux' | |
run: | | |
curl -L "https://github.com/Tracktion/pluginval/releases/download/${{env.PLUGINVAL_VERSION}}/pluginval_${{ matrix.artifact }}.zip" -o pluginval.zip | |
unzip pluginval | |
./pluginval --strictness-level 10 --validate-in-process --verbose --output-dir "." --validate "${{ env.PROJECT_NAME }}_artefacts/${{ env.BUILD_TYPE }}/VST3/${{ env.PROJECT_NAME }}.vst3" | |
- name: Pluginval Mac | |
working-directory: ${{ env.BUILD_DIR }} | |
if: matrix.artifact == 'MacOS' | |
run: | | |
curl -L "https://github.com/Tracktion/pluginval/releases/download/${{env.PLUGINVAL_VERSION}}/pluginval_${{ matrix.artifact }}.zip" -o pluginval.zip | |
unzip pluginval | |
pluginval.app/Contents/MacOS/pluginval --strictness-level 10 --validate-in-process --verbose --output-dir "." --validate "${{ env.PROJECT_NAME }}_artefacts/${{ env.BUILD_TYPE }}/VST3/${{ env.PROJECT_NAME }}.vst3" | |
- name: Pluginval Windows | |
shell: cmd | |
working-directory: ${{ env.BUILD_DIR }} | |
if: matrix.artifact == 'Windows' | |
run: | | |
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest https://github.com/Tracktion/pluginval/releases/download/${{env.PLUGINVAL_VERSION}}/pluginval_Windows.zip -OutFile pluginval.zip" | |
powershell -Command "Expand-Archive pluginval.zip -DestinationPath ." | |
pluginval.exe --strictness-level 10 --validate-in-process --output-dir "./bin" --validate "${{ env.PROJECT_NAME }}_artefacts/${{ env.BUILD_TYPE }}/VST3/${{ env.PROJECT_NAME }}.vst3" | |
if %ERRORLEVEL% neq 0 { exit /b 1 } | |
- name: Remove shared lib before zip packaging | |
working-directory: ${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}_artefacts/${{ env.BUILD_TYPE }} | |
run: | | |
cmake -E rm -f lib${{ env.PROJECT_NAME }}_SharedCode.a ${{ env.PROJECT_NAME }}_SharedCode.lib | |
- name: Rename folder to ${{ env.PROJECT_NAME }} before zip packaging | |
working-directory: ${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}_artefacts | |
run: | | |
cmake -E rename ${{ env.BUILD_TYPE }} ${{ env.PROJECT_NAME }}-${{ matrix.artifact }} | |
- name: Zip | |
working-directory: ${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}_artefacts | |
run: cmake -E tar cfv ${{ env.PROJECT_NAME }}-${{ matrix.artifact }}.zip --format=zip ${{ env.PROJECT_NAME }}-${{ matrix.artifact }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}_artefacts/${{ env.PROJECT_NAME }}-${{ matrix.artifact }}.zip | |
name: ${{ env.PROJECT_NAME }}-${{ matrix.artifact }} | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
steps: | |
- name: Get the release version | |
id: get_release_version | |
run: echo ::set-output name=RELEASE_VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Download All Artifacts | |
id: download_artifacts | |
uses: actions/download-artifact@v4 | |
- name: Add version name to the files that will be published | |
run: | | |
mv ${{ steps.download_artifacts.outputs.download-path }}/${{ env.PROJECT_NAME }}-Windows/${{ env.PROJECT_NAME }}-Windows.zip ./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-Windows.zip | |
mv ${{ steps.download_artifacts.outputs.download-path }}/${{ env.PROJECT_NAME }}-MacOS/${{ env.PROJECT_NAME }}-MacOS.zip ./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-MacOS.zip | |
mv ${{ steps.download_artifacts.outputs.download-path }}/${{ env.PROJECT_NAME }}-Linux/${{ env.PROJECT_NAME }}-Linux.zip ./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-Linux.zip | |
- name: Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-Windows.zip | |
./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-Linux.zip | |
./${{ env.PROJECT_NAME }}-${{ steps.get_release_version.outputs.RELEASE_VERSION }}-MacOS.zip |