Skip to content

Commit 57be1b0

Browse files
author
Simon-L
committed
Go Github Actions!
1 parent 4df07d2 commit 57be1b0

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

.github/workflows/build-plugin.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Taken from https://github.com/baconpaul/BaconPlugs/blob/main/.github/workflows/build-plugin.yml
2+
# Base image by @qno!
3+
name: Build VCV Rack Plugin
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- 'releases/**'
9+
pull_request:
10+
11+
env:
12+
rack-sdk-version: 2.1.2
13+
rack-plugin-toolchain-dir: /home/build/rack-plugin-toolchain
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
21+
modify-plugin-version:
22+
name: Modify plugin version
23+
runs-on: ubuntu-latest
24+
if: github.repository_owner == 'Simon-L'
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: actions/cache@v2
28+
id: plugin-version-cache
29+
with:
30+
path: plugin.json
31+
key: ${{ github.sha }}-${{ github.run_id }}
32+
- run: |
33+
gitrev=`git rev-parse --short HEAD`
34+
pluginversion=`jq -r '.version' plugin.json`
35+
echo "Set plugin version from $pluginversion to $pluginversion-$gitrev"
36+
cat <<< `jq --arg VERSION "$pluginversion-nightly-$gitrev" '.version=$VERSION' plugin.json` > plugin.json
37+
# only modify plugin version if no tag was created
38+
if: "! startsWith(github.ref, 'refs/tags/v')"
39+
40+
build:
41+
name: ${{ matrix.platform }}
42+
needs: modify-plugin-version
43+
runs-on: ubuntu-latest
44+
if: github.repository_owner == 'Simon-L'
45+
container:
46+
image: ghcr.io/qno/rack-plugin-toolchain-win-linux:v2
47+
options: --user root
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
platform: [ win, linux ]
52+
steps:
53+
- uses: actions/checkout@v3
54+
with:
55+
submodules: recursive
56+
- uses: actions/cache@v2
57+
id: plugin-version-cache
58+
with:
59+
path: plugin.json
60+
key: ${{ github.sha }}-${{ github.run_id }}
61+
- name: Build plugin
62+
run: |
63+
export PLUGIN_DIR=$GITHUB_WORKSPACE
64+
pushd ${{ env.rack-plugin-toolchain-dir }}
65+
sed -i "s/-G 'MSYS Makefiles'/-DCMAKE_SYSTEM_NAME=Windows/g" Rack-SDK-win/dep.mk
66+
make plugin-build-${{ matrix.platform }}
67+
- name: Upload artifact
68+
uses: actions/upload-artifact@v2
69+
with:
70+
path: ${{ env.rack-plugin-toolchain-dir }}/plugin-build
71+
name: ${{ matrix.platform }}
72+
73+
build-mac:
74+
name: mac
75+
needs: modify-plugin-version
76+
runs-on: macos-12
77+
if: github.repository_owner == 'Simon-L'
78+
steps:
79+
- uses: actions/checkout@v3
80+
with:
81+
submodules: recursive
82+
- uses: actions/cache@v2
83+
id: plugin-version-cache
84+
with:
85+
path: plugin.json
86+
key: ${{ github.sha }}-${{ github.run_id }}
87+
- name: Get Rack-SDK
88+
run: |
89+
pushd $HOME
90+
curl -o Rack-SDK.zip https://vcvrack.com/downloads/Rack-SDK-${{ env.rack-sdk-version }}-mac.zip
91+
unzip Rack-SDK.zip
92+
- name: Build plugin
93+
run: |
94+
export RACK_DIR=$HOME/Rack-SDK
95+
make -j dep
96+
make -j dist
97+
- name: Upload artifact
98+
uses: actions/upload-artifact@v2
99+
with:
100+
path: dist
101+
name: mac
102+
103+
publish:
104+
name: Publish Release
105+
# only create a release if a tag was created that is called e.g. v1.2.3
106+
# see also https://vcvrack.com/manual/Manifest#version
107+
if: startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'Simon-L'
108+
runs-on: ubuntu-latest
109+
needs: [ build, build-mac ]
110+
steps:
111+
- uses: actions/checkout@v3
112+
- uses: FranzDiebold/[email protected]
113+
- name: Check if plugin version matches tag
114+
run: |
115+
pluginversion=`jq -r '.version' plugin.json`
116+
if [ "v$pluginversion" != "${{ env.GITHUB_REF_NAME }}" ]; then
117+
echo "Plugin version from plugin.json 'v$pluginversion' doesn't match with tag version '${{ env.GITHUB_REF_NAME }}'"
118+
exit 1
119+
fi
120+
- name: Create Release
121+
uses: actions/create-release@v1
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
tag_name: ${{ github.ref }}
126+
release_name: Release ${{ github.ref }}
127+
body: |
128+
${{ env.GITHUB_REPOSITORY_NAME }} VCV Rack Plugin ${{ env.GITHUB_REF_NAME }}
129+
draft: false
130+
prerelease: false
131+
- uses: actions/download-artifact@v2
132+
with:
133+
path: _artifacts
134+
- name: Upload release assets
135+
uses: svenstaro/upload-release-action@v2
136+
with:
137+
repo_token: ${{ secrets.GITHUB_TOKEN }}
138+
file: _artifacts/**/*.vcvplugin
139+
tag: ${{ github.ref }}
140+
file_glob: true
141+
142+
publish-nightly:
143+
name: Publish Nightly
144+
# only create a release if a tag was created that is called e.g. v1.2.3
145+
# see also https://vcvrack.com/manual/Manifest#version
146+
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'Simon-L' }}
147+
runs-on: ubuntu-latest
148+
needs: [ build, build-mac ]
149+
steps:
150+
- uses: actions/download-artifact@v2
151+
with:
152+
path: _artifacts
153+
- name: Delete old release assets
154+
uses: mknejp/delete-release-assets@v1
155+
with:
156+
token: ${{ github.token }}
157+
tag: Nightly # This may also be of the form 'refs/tags/staging'
158+
assets: '*'
159+
- name: Upload release assets
160+
uses: svenstaro/upload-release-action@v2
161+
with:
162+
repo_token: ${{ secrets.GITHUB_TOKEN }}
163+
file: _artifacts/**/*.vcvplugin
164+
tag: Nightly
165+
file_glob: true

0 commit comments

Comments
 (0)