Skip to content

Commit

Permalink
Use one .env file to plugin name, version, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellmattryan committed Nov 18, 2024
1 parent f390080 commit bf0d8b1
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
COMPANY_NAME="Black Box Audio"
PLUGIN_NAME="Plugin"
PLUGIN_VERSION="X.Y.Z"
PLUGIN_BUNDLE_ID="com.bbx-audio.plugin-name"
12 changes: 6 additions & 6 deletions .github/workflows/cd.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ jobs:
os: windows-2022
with:
os: ${{ matrix.os }}
plugin_name: Rotor
plugin_version: 1.1.0-beta.1
plugin_bundle_id: com.bbx-audio.rotor
secrets: inherit

Release:
Expand All @@ -49,16 +46,19 @@ jobs:
permissions:
contents: write
id-token: write
env:
PLUGIN_NAME: Rotor
PLUGIN_VERSION: 1.1.0-beta.1
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4

- name: Import Environment Variables
run: |
source .env
echo "PLUGIN_NAME=$PLUGIN_NAME" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_ENV
- name: Set Environment Variables
run: |
VERSION=${GITHUB_REF#refs/tags/v}
Expand Down
59 changes: 30 additions & 29 deletions .github/workflows/reusable.package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,42 @@ on:
os:
required: true
type: string
plugin_name:
required: true
type: string
plugin_version:
required: true
type: string
plugin_bundle_id:
required: true
type: string

defaults:
run:
shell: bash

jobs:
Package:
name: Package ${{ inputs.plugin_name }}-${{ inputs.plugin_version }}-${{ inputs.os }}
name: Package (${{ inputs.os }})
runs-on: ${{ inputs.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Import Environment Variables
run: |
source .env
echo "PLUGIN_NAME=$PLUGIN_NAME" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$PLUGIN_VERSION" >> $GITHUB_ENV
echo "PLUGIN_BUNDLE_ID=$PLUGIN_BUNDLE_ID" >> $GITHUB_ENV
- name: Set Environment Variables
run: |
echo "VST3_PATH=${{ env.PLUGIN_NAME }}.vst3" >> $GITHUB_ENV
echo "AU_PATH=${{ env.PLUGIN_NAME }}.component" >> $GITHUB_ENV
echo "INSTALLER_NAME=${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}-${{ runner.os }}" >> $GITHUB_ENV
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: ${{ inputs.plugin_name }}-${{ runner.os }}
name: ${{ env.PLUGIN_NAME }}-${{ runner.os }}

- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ inputs.plugin_name }}-${{ runner.os }}

- name: Set Environment Variables
run: |
echo "VST3_PATH=${{ inputs.plugin_name }}.vst3" >> $GITHUB_ENV
echo "AU_PATH=${{ inputs.plugin_name }}.component" >> $GITHUB_ENV
echo "INSTALLER_NAME=${{ inputs.plugin_name }}-${{ inputs.plugin_version }}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ inputs.plugin_name }}-${{ inputs.plugin_version }}-${{ runner.os }}" >> $GITHUB_ENV
name: ${{ env.PLUGIN_NAME }}-${{ runner.os }}

- name: Import Certificates (MacOS)
uses: apple-actions/import-codesign-certs@v3
Expand Down Expand Up @@ -74,14 +72,17 @@ jobs:

- name: Build Installer (MacOS)
if: ${{ runner.os == 'macOS' }}
run: packagesbuild packaging/Rotor.pkgproj
run: |
PKGPROJ_FILE="packaging/$PLUGIN_NAME.pkgproj"
sed -i.bak "s/{{VERSION}}/$PLUGIN_VERSION/g" "$PKGPROJ_FILE"
packagesbuild "$PKGPROJ_FILE"
- name: Sign Installer (MacOS)
if: ${{ runner.os == 'macOS' }}
run: |
mkdir -p packaging/build/signed
productsign -s "${{ secrets.DEVELOPER_ID_INSTALLER }}" "packaging/build/${{ inputs.plugin_name }}.pkg" "packaging/build/signed/${{ inputs.plugin_name }}.pkg"
pkgutil --check-signature "packaging/build/signed/${{ inputs.plugin_name }}.pkg"
productsign -s "${{ secrets.DEVELOPER_ID_INSTALLER }}" "packaging/build/${{ env.PLUGIN_NAME }}.pkg" "packaging/build/signed/${{ env.PLUGIN_NAME }}.pkg"
pkgutil --check-signature "packaging/build/signed/${{ env.PLUGIN_NAME }}.pkg"
- name: Package Installer (MacOS)
if: ${{ runner.os == 'macOS' }}
Expand All @@ -91,11 +92,11 @@ jobs:
npm install -g appdmg
mkdir -p packaging/dmg
mv packaging/README.pdf packaging/dmg
mv packaging/build/signed/${{ inputs.plugin_name }}.pkg packaging/dmg
mv packaging/build/signed/${{ env.PLUGIN_NAME }}.pkg packaging/dmg
# Create the .dmg
cd packaging && appdmg dmg.json "${{ env.INSTALLER_NAME }}.dmg"
codesign -s "${{ secrets.DEVELOPER_ID_APP }}" --timestamp -i ${{ inputs.plugin_bundle_id }} --force "${{ env.INSTALLER_NAME }}.dmg"
codesign -s "${{ secrets.DEVELOPER_ID_APP }}" --timestamp -i ${{ env.PLUGIN_BUNDLE_ID }} --force "${{ env.INSTALLER_NAME }}.dmg"
xcrun notarytool submit "${{ env.INSTALLER_NAME }}.dmg" --apple-id ${{ secrets.APPLE_NOTARIZATION_USERNAME }} --password ${{ secrets.APPLE_NOTARIZATION_PASSWORD }} --team-id ${{ secrets.DEVELOPER_TEAM_ID }} --wait
xcrun stapler staple "${{ env.INSTALLER_NAME }}.dmg"
Expand All @@ -111,8 +112,8 @@ jobs:
id: cache-ipp
uses: actions/cache@v4
with:
key: ipp-v5
path: C:\Program Files (x86)\Intel
key: ipp-v5
path: C:\Program Files (x86)\Intel

- name: Install IPP (Windows)
if: ${{ runner.os == 'Windows' && steps.cache-ipp.outputs.cache-hit != 'true' }}
Expand All @@ -125,13 +126,13 @@ jobs:
if: ${{ runner.os == 'Windows' && steps.cache-ipp.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
key: ipp-v5
path: C:\Program Files (x86)\Intel
key: ipp-v5
path: C:\Program Files (x86)\Intel

- name: Build Installer (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
iscc "packaging\${{ inputs.plugin_name }}.iss"
iscc "packaging\${{ env.PLUGIN_NAME }}.iss"
mv "packaging\Output\${{ env.INSTALLER_NAME }}.exe" .
- name: Upload Installer (Windows)
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ jobs:
os: [ 'macos-13' , 'windows-2022' ]
with:
os: ${{ matrix.os }}
plugin_name: Rotor
plugin_version: 1.1.0-beta.1
secrets: inherit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ packaging/Output
# CMake
**/cmake-build-*

# .env file (more for configuration than secrets)
**/*.env

# ================
# Google Cloud
# ================
Expand Down
24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@ cmake_minimum_required(VERSION 3.15)
# Declaring targets and describing source/ binary directories
project(Rotor VERSION 1.0.0)

# Handle environment variables
set(ENV_FILE "${CMAKE_SOURCE_DIR}/.env")
include("${CMAKE_SOURCE_DIR}/cmake/load_env.cmake")
load_env_file("${ENV_FILE}")

# Declare dependency on JUCE (as installed on the local system)
add_subdirectory(vendor/juce)

juce_add_plugin(Rotor
VERSION "1.0.0"
COMPANY_NAME "Black Box Audio"
COMPANY_NAME "${COMPANY_NAME}"
COMPANY_WEBSITE "https://bbx-audio.com"
# CAUTION: Only X.Y.Z format is allowed, no stage or stage versions (e.g. 1.0.0-beta.1)
VERSION "1.0.0"
BUNDLE_ID "${PLUGIN_BUNDLE}"
PRODUCT_NAME "${PLUGIN_NAME}"
PLUGIN_NAME "${PLUGIN_NAME}"
PLUGIN_CODE "${PLUGIN_CODE}"
PLUGIN_MANUFACTURER_CODE BBxA
FORMATS AU VST3
IS_SYNTH FALSE
IS_MIDI_EFFECT FALSE
NEEDS_MIDI_INPUT FALSE
NEEDS_MIDI_OUTPUT FALSE
PLUGIN_MANUFACTURER_CODE BBxA
PLUGIN_CODE Rotr
PLUGIN_NAME Rotor
BUNDLE_ID "com.bbx-audio.rotor"
FORMATS AU VST3
PRODUCT_NAME "Rotor")
NEEDS_MIDI_OUTPUT FALSE)

# Create universal binaries to handle Intel- and ARM-based MacOS
set_target_properties(Rotor PROPERTIES OSX_ARCHITECTURES "x86_64;arm64")
Expand Down
21 changes: 21 additions & 0 deletions cmake/load_env.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Function to load and parse a .env file
function(load_env_file env_file)
if (EXISTS "${env_file}")
file(READ "${env_file}" ENV_CONTENT)
string(REGEX REPLACE "\n" ";" ENV_LINES "${ENV_CONTENT}")
foreach (line ${ENV_LINES})
string(STRIP "${line}" line)
string(REGEX MATCH "^[A-Za-z_][A-Za-z0-9_]*=.*" is_valid "${line}")
if (is_valid)
string(REPLACE "=" ";" kv_pair "${line}")
list(GET kv_pair 0 key)
list(GET kv_pair 1 value)
string(STRIP "${key}" key)
string(STRIP "${value}" value)
set("${key}" "${value}" PARENT_SCOPE)
endif ()
endforeach ()
else ()
message(FATAL_ERROR "The .env file '${env_file}' does not exist.")
endif ()
endfunction()
6 changes: 3 additions & 3 deletions packaging/Rotor.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define PluginName "Rotor"
#define Version "1.1.0-beta.1"
#define Publisher "Black Box Audio"
#define PluginName GetEnv('PLUGIN_NAME')
#define Version GetEnv('PLUGIN_VERSION')
#define Publisher GetEnv('COMPANY_NAME')
#define Year GetDateTimeString("yyyy","","")

[Setup]
Expand Down
4 changes: 2 additions & 2 deletions packaging/Rotor.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
<key>USE_HFS+_COMPRESSION</key>
<false/>
<key>VERSION</key>
<string>1.1.0-beta.1</string>
<string>{{VERSION}}</string>
</dict>
<key>TYPE</key>
<integer>0</integer>
Expand Down Expand Up @@ -1152,7 +1152,7 @@
<key>USE_HFS+_COMPRESSION</key>
<false/>
<key>VERSION</key>
<string>1.1.0-beta.1</string>
<string>{{VERSION}}</string>
</dict>
<key>TYPE</key>
<integer>0</integer>
Expand Down

0 comments on commit bf0d8b1

Please sign in to comment.