Update 7: update the workflow actions to use the latest Rack-SDK version for Mac builds, see also this post.
Update 6: update the workflow actions to use Toolchain Docker image version 10, see also this post.
Update 5: update the workflow actions, added Mac ARM64 cross compile build job
Update 4: update the workflow actions to latest toolchain image version 6 changes.
Update 3: update the workflow actions to more recent versions (see also this post), update toolchain image version.
Update 2: for using the official Rack Plugin Toolchain example (Windows and Linux only) see this post.
Update 1: for Rack2 SDK example see this post.
Hello,
after I optimized the Azure pipeline definition for @Aria_Salvatrice, I decided to create an Github Actions Workflow for automated builds of VCV Rack plugins on Github. This is based on the Azure pipelines that are discussed mostly in this topic - Azure Pipelines for Github allows build of plugin
The setup of Github Actions is much simpler for a repository than to use 3rd party CI services (like Azure, Tracis-CI, etc.), as it requires
no setup at all. All you have to do is create a worklow under .github/workflows
inside the repository.
I created a demo repository from where you can copy and put the https://github.com/qno/vcv-plugin-github-actions-example/blob/main/.github/workflows/build-plugin.yml into your own plugin repo and everything works than out of the box.
name: Build VCV Rack Plugin
on: [push, pull_request]
env:
rack-sdk-version: latest
rack-plugin-toolchain-dir: /home/build/rack-plugin-toolchain
defaults:
run:
shell: bash
jobs:
modify-plugin-version:
name: Modify plugin version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: plugin-version-cache
with:
path: plugin.json
key: ${{ github.sha }}-${{ github.run_id }}
- run: |
gitrev=`git rev-parse --short HEAD`
pluginversion=`jq -r '.version' plugin.json`
echo "Set plugin version from $pluginversion to $pluginversion-$gitrev"
cat <<< `jq --arg VERSION "$pluginversion-$gitrev" '.version=$VERSION' plugin.json` > plugin.json
# only modify plugin version if no tag was created
if: "! startsWith(github.ref, 'refs/tags/v')"
build:
name: ${{ matrix.platform }}
needs: modify-plugin-version
runs-on: ubuntu-latest
container:
image: ghcr.io/qno/rack-plugin-toolchain-win-linux
options: --user root
strategy:
matrix:
platform: [win-x64, lin-x64]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/cache@v3
id: plugin-version-cache
with:
path: plugin.json
key: ${{ github.sha }}-${{ github.run_id }}
- name: Build plugin
run: |
export PLUGIN_DIR=$GITHUB_WORKSPACE
pushd ${{ env.rack-plugin-toolchain-dir }}
make plugin-build-${{ matrix.platform }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ${{ env.rack-plugin-toolchain-dir }}/plugin-build
name: ${{ matrix.platform }}
build-mac:
name: mac
needs: modify-plugin-version
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
platform: [x64, arm64]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/cache@v3
id: plugin-version-cache
with:
path: plugin.json
key: ${{ github.sha }}-${{ github.run_id }}
- name: Get Rack-SDK
run: |
pushd $HOME
wget -O Rack-SDK.zip https://vcvrack.com/downloads/Rack-SDK-${{ env.rack-sdk-version }}-mac-${{ matrix.platform }}.zip
unzip Rack-SDK.zip
- name: Build plugin
run: |
CROSS_COMPILE_TARGET_x64=x86_64-apple-darwin
CROSS_COMPILE_TARGET_arm64=arm64-apple-darwin
export RACK_DIR=$HOME/Rack-SDK
export CROSS_COMPILE=$CROSS_COMPILE_TARGET_${{ matrix.platform }}
make dep
make dist
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: dist/*.vcvplugin
name: mac-${{ matrix.platform }}
publish:
name: Publish plugin
# only create a release if a tag was created that is called e.g. v1.2.3
# see also https://vcvrack.com/manual/Manifest#version
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build, build-mac]
steps:
- uses: actions/checkout@v3
- uses: FranzDiebold/github-env-vars-action@v2
- name: Check if plugin version matches tag
run: |
pluginversion=`jq -r '.version' plugin.json`
if [ "v$pluginversion" != "${{ env.CI_REF_NAME }}" ]; then
echo "Plugin version from plugin.json 'v$pluginversion' doesn't match with tag version '${{ env.CI_REF_NAME }}'"
exit 1
fi
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: Release ${{ env.CI_REF_NAME }}
body: |
${{ env.CI_REPOSITORY_NAME }} VCV Rack Plugin ${{ env.CI_REF_NAME }}
draft: false
prerelease: false
- uses: actions/download-artifact@v3
with:
path: _artifacts
- name: Upload release assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _artifacts/**/*.vcvplugin
tag: ${{ github.ref }}
file_glob: true
The workflow does this:
Build plugin
- On each push to Github and pull request a build pipeline is triggered that compiles the plugin for Windows, MacOS and Linux with the Makefile from Rack-SDK
- Each pipeline stores the built plugin variants as artifacts that can be accessed via the Actions tab under the according workflow run
- A pipeline build modifies the plugin version on the fly by prepending the short git commit hash to the version in
plugin.json
(e.g. version1.2.3
becomes1.2.3-4a94fba
) Note: This is only done when the build is not triggered from a tag! - The
plugin.mk
file in the RACK-SDK gets patched to use 7zip on Windows instead if zip command
Creating a Release
To create an automated Release on the Github repository, a developer must create and push a tag to the repository.
This follows the convention which is described at Plugin Manifest - VCV Rack Manual.
A tag must be named vX.Y.Z
, where X.Y.Z represents the current version in the plugin.json
, e.g. v1.2.3
.
If the build is triggered by tag then the workflow creates und publish a new Release based on the tag version.
The built plugin variants are attached as assets to the release.
The release job contains a check that verifies if the created tag matches the current plugin version in plugin.json
If the version and tag are not matching the Release job gets canceled.