Skip to content

Azure Pipelines CI

Guillaume Piolat edited this page Sep 16, 2019 · 10 revisions

This is step-by-step guide on how to setup Azure Pipelines Continuous Integration for building Dplug-based plugins.

  1. Add an azure-pipelines.yml to your repository. Commit and push. Follow the template below to fill it.
  2. Register Azure DevOps account here.
  3. Click New project in the Azure DevOps dashboard. Optionally make project public if you want people to access the builds.
  4. Here is a good time to add aeffect.h and aeffectx.h as secure files. See below..
  5. Click Pipelines in the left panel and click Create Pipeline.
  6. Select one the options for source repositery (such as Github (YAML) or Bitbucket (YAML) and fill the repositery information.
  7. Press Confirm password and then Approve and Install to give Azure Pipelines access to your repository.
  8. Click Starter pipeline to create new file in your repository. UI will prompt you to commit it to your repository as the last step. This will create and commit azure-pipelines.yml file in the root of the repository. Alternatively select Existing Azure Pipelines YAML file and choose already committed file in your repository. This way you can choose the filename and path.
  9. To access build artifacts click the build and the Artifacts column on the right
  10. Press Save and Run to finish the setup.

Creating azure-pipelines.yml file

Here is template of azure-pipelines.yml file that builds dplug plugin with Ubuntu and Windows

# Common variables for all platforms (ldc is hardcoded in windows job)
variables:
  DC: ldc
  DVersion: 1.17.0
  arch: x64

# Trigger on new commit or tag. By default tags aren't built
trigger:
- '*'
- refs/tags/v*

# Nightly builds
schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - master
    - releases/*

jobs:
- job: Linux
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
    - checkout: self
      submodules: true
      fetchDepth: 50

# Uncomment these DownloadSecureFile tasks + script to use secure files. Or delete if not needed
#     - task: DownloadSecureFile@1
#       name: aeffect
#       inputs:
#         secureFile: 'aeffect.h'
#     - task: DownloadSecureFile@1
#       name: aeffectx
#       inputs:
#         secureFile: 'aeffectx.h'
#     # Creates VST2_SDK\pluginterfaces\vst2.x folder and copies aeffect.h and aeffectx.h there
#     - script: |
#         mkdir VST2_SDK\pluginterfaces\vst2.x
#         cp $(aeffect.secureFilePath) VST2_SDK\pluginterfaces\vst2.x\aeffect.h
#         cp $(aeffectx.secureFilePath) VST2_SDK\pluginterfaces\vst2.x\aeffectx.h
#       displayName: Download secure files
      
    # Installs libx11-dev package, ldc, dub, dplug-build
    - script: |
        echo on
        # exit as soon as any line in the bash script fails
        set -ex
        # There is no permissions in default directory for system changes, so make sure to cd ..
        cd ..
        
        # Install libs
        sudo apt-get -yq install libx11-dev
        
        # Install compiler
        curl -fsS https://dlang.org/install.sh | bash -s $(DC)-$(DVersion) -a
        ~/dlang/install.sh list
        source ~/dlang/$(DC)-$(DVersion)/activate
        ldc2 --version
        dub --version
        
        # Install dplug-build
        git clone --depth 1 https://github.com/AuburnSounds/Dplug dplug
        cd dplug/tools/dplug-build
        dub build
        sudo ln -sf $(pwd)/dplug-build /usr/bin/dplug-build
      displayName: Install
      
    - script: |
        echo on
        # Environment variables are not preserved between steps.
        source ~/dlang/$(DC)-$(DVersion)/activate
        export VST2_SDK="$(pwd)/VST2_SDK"
        
        # Here you can customize the flags, or build multiple plugins
        dplug-build -c VST -c VST3 -c LV2 --installer --final
      displayName: Build
    
    # This task uploads the builds directory that contains all artifacts produced by dplug-build
    # You may need to repeat this for each plugin that you build
    # Pattern matching is not supported here
    - upload: $(System.DefaultWorkingDirectory)/builds/
      artifact: linux64
      
- job: Windows
  pool:
    vmImage: 'windows-2019'
  variables:
    VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
    ARCH: x64
  steps:
    - checkout: self
      submodules: true
      fetchDepth: 50
    
# Uncomment these DownloadSecureFile tasks + script to use secure files. Or delete if not needed
#     - task: DownloadSecureFile@1
#       name: aeffect
#       inputs:
#         secureFile: 'aeffect.h'
#     - task: DownloadSecureFile@1
#       name: aeffectx
#       inputs:
#         secureFile: 'aeffectx.h'
#     - script: |
#         echo on
#         mkdir VST2_SDK\pluginterfaces\vst2.x
#         echo $(aeffect.secureFilePath)
#         COPY $(aeffect.secureFilePath) VST2_SDK\pluginterfaces\vst2.x\aeffect.h
#         COPY $(aeffectx.secureFilePath) VST2_SDK\pluginterfaces\vst2.x\aeffectx.h
#       displayName: Download secure files
    
    - powershell: |
        echo on
        cd ..
        
        # Download dplug
        git clone --depth 1 https://github.com/AuburnSounds/Dplug dplug
        
        # Download compiler
        $version = $env:DVersion;
        $url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-windows-multilib.7z";
        Invoke-WebRequest $url -OutFile "compiler.archive";
        7z x compiler.archive > $null;
        Rename-Item ldc2-$($version)-windows-multilib ldc2;
      displayName: Download dplug and ldc
      
    - script: |
        echo on
        cd ..
        set PATH=%CD%\ldc2\bin;%PATH%
        
        pushd dplug\tools\dplug-build
        call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%ARCH%
        dub build
        popd
        copy dplug\tools\dplug-build\dplug-build.exe ldc2\bin\dplug-build.exe
      displayName: Build dplug-build
      
    - script: |
        echo on
        set PATH=%CD%/../ldc2/bin;%PATH%
        set VST2_SDK=%CD%/VST2_SDK
        call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%ARCH%
        
        # Here ldc2, dub and dplug-build tools are available. Customize as needed
        dplug-build -a x86_64 -c VST -c VST3 -c LV2 --installer --final
      displayName: Build

    - upload: $(System.DefaultWorkingDirectory)/builds/
      artifact: win64

Uploading aeffect.h and aeffectx.h as secure files

In order to build VST2 plugins you need to have aeffect.h and aeffectx.h headers in VST2_SDK\pluginterfaces\vst2.x directory during the build, with VST2_SDK environment variable pointing to directory containing pluginterfaces directory.

If your repository is private you may include those files directly in your repository. But for public repository you want to them to be hidden. For this you can use secure files feature:

  1. Go to your project on Azure DevOps
  2. Open Pipelines
  3. Click Library
  4. Click Secure files
  5. Add aeffect.h and aeffectx.h files
  6. In Pipeline permissions, check the "Authorize for use in all pipelines"
  7. Uncomment download of secure files tasks in the azure-pipelines.yml file
  8. On first run notification will pop up, you need to grant pipeline the access to secure files

Extra links

D projects using Azure pipelines