Hello everyone
I just wanted to share this little project (after inspiration from yesterday’s SC meetup):
Automatically building, compiling and releasing SuperCollider plugins using Github Actions. I just set this up on my little personal plugins repo.
Here is the yaml file I used:
.github/workflows/cmake.yml:
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get SC source code
run: git clone https://github.com/supercollider/supercollider.git ${{github.workspace}}/supercollider
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake .. -DCMAKE_BUILD_TYPE='Release' -DSC_PATH=${{github.workspace}}/supercollider -DCMAKE_INSTALL_PREFIX=/${{github.workspace}}/build/install
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config "Release" --target install
# Gather all files in a zip
- name: Zip up build
shell: bash
working-directory: ${{github.workspace}}/build
run: zip -r MKPlugins install/MKPlugins
# Publish build
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{github.workspace}}/build/install/MKPlugins.zip
asset_name: MKPlugins.zip
asset_content_type: application/zip
With this, whenever I push to my github repo with a new tag prefixed v
Github will trigger the build workflow and create a new release.
So, this local command:
git tag v0.0.108 && git push origin --tags
Becomes MKPlugins-v0.0.108 after about 45 seconds of Github chewing on the build.
The yaml syntax for these builds is a PITA and a bit underdocumented IMO (like, it really surprised me how much chaos wrong indentation causes (and how bad the resulting error messages are)).
I know SC core has moved to this workflow as well.
Cross platform?
The yaml file above only makes a Linux build.
Can someone give me pointers on how to make this build cross platform to build macos and windows plugins as well? This really could be an awesome future for plugin developers because it would make it easy to have personal repos with easily downloadable prebuilds for the users. Woohoo.