Skip to content

Commit

Permalink
Add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
koteq committed Mar 21, 2023
1 parent 4fd77da commit 29057fb
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 1 deletion.
92 changes: 92 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 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
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ cmake_minimum_required(VERSION 3.15)
# This cannot have spaces (but PRODUCT_NAME can)
set(PROJECT_NAME "LightHost")

# Read project version from env variable, allowing it to be provided by CI/CD workflow
set(PROJECT_VERSION $ENV{PROJECT_VERSION})
if(NOT PROJECT_VERSION)
set(PROJECT_VERSION 0.0.0.0)
endif()

# For simplicity, the name of the project is also the name of the target
project(${PROJECT_NAME} VERSION 1.2.2)
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION})

# Allow to use deprecated MessageManager::runDispatchLoopUntil
add_compile_definitions(JUCE_MODAL_LOOPS_PERMITTED)
Expand Down

0 comments on commit 29057fb

Please sign in to comment.