Skip to content

Add GitHub Actions workflow #15

Add GitHub Actions workflow

Add GitHub Actions workflow #15

Workflow file for this run

# Adapted from Pamplejuce template
# https://github.com/sudara/pamplejuce/blob/580314ceb0/.github/workflows/cmake_ctest.yml
# Reference Documentation
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Build
on:
workflow_dispatch: # lets you run a build from the UI
push:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
PROJECT_NAME: LightHost
BUILD_TYPE: Release
BUILD_DIR: Builds
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CMAKE_BUILD_PARALLEL_LEVEL: 3 # Use up to 3 cpus to build juceaide, etc
jobs:
build:
name: Build for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Windows
os: windows-latest
steps:
- name: Set up Clang
if: ${{ matrix.name != 'macOS' }}
uses: egor-tensin/setup-clang@v1
- name: Set up Ninja
if: runner.os == 'Windows'
shell: bash
run: choco install ninja
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Environment Variables
shell: bash
run: |
VERSION_REGEX='^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)$'
if [[ $GITHUB_REF =~ $VERSION_REGEX ]]; then
PROJECT_VERSION="${BASH_REMATCH[1]}"
else
PROJECT_VERSION="0.0.0.${GITHUB_RUN_NUMBER}"
fi
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
- name: CMake Configure
shell: bash
run: cmake -B ${{ env.BUILD_DIR }} -G Ninja -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE}} .
- name: CMake Build
shell: bash
run: cmake --build ${{ env.BUILD_DIR }} --config ${{ env.BUILD_TYPE }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_NAME }}
path: "${{ env.BUILD_DIR }}/${{ env.PROJECT_NAME }}_artefacts/${{ env.BUILD_TYPE }}"
release:
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: build
steps:
- name: Get Artifacts
uses: actions/download-artifact@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
prerelease: true
# download-artifact puts these files in their own dirs...
# Using globs sidesteps having to pass the version around
files: |
*/*.exe
*/*.zip
*/*.dmg