You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
5.1KB

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