
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- develop

pool:
  vmImage: 'ubuntu-latest'

variables:
  emscripten_container_name : 'csound_emscripten_build_run'
  emscripten_zip_path : '/csound/Emscripten/' 
  emscripten_artifact : 'Csound6.13.0-Web.zip'
  emscripten_docker_image: 'sjamble/csound_emscripten'
  android_container_name : 'csound_android_build_run'
  android_zip_path : '/csound/Android/' 
  android_artifact : 'Csound6.13.0-Android.zip'
  android_docker_image: 'sjamble/csound_android'
  
jobs:
  - job: "Emscripten_Build"
    steps:
    - script: |
        sudo apt-get install docker -y
      displayName: Setting up docker cli

    - script: |
        sudo docker run --name $(emscripten_container_name) -i $(emscripten_docker_image)
      displayName: Building the Csound emscripten build

    - script: |
        sudo docker cp $(emscripten_container_name):$(emscripten_zip_path)$(emscripten_artifact) $(System.DefaultWorkingDirectory)/
      displayName: Extracting web build file from docker image

    - task: PublishPipelineArtifact@1
      inputs:
        path: $(System.DefaultWorkingDirectory)/$(emscripten_artifact)
        artifact: Csound6.13.0-WEB

  - job: Android_Build
    steps:
    - script: |
        sudo apt-get install docker -y
      displayName: Setting up docker cli

    - script: |
        sudo docker run --name $(android_container_name) -i $(android_docker_image)
      displayName: Building the Csound Android build

    - script: |
        sudo docker cp $(android_container_name):$(android_zip_path)$(android_artifact) $(System.DefaultWorkingDirectory)/
      displayName: Extracting android build file from docker image

    - task: PublishPipelineArtifact@1
      inputs:
        path: $(System.DefaultWorkingDirectory)/$(android_artifact)
        artifact: Csound6.13.0-ANDROID

  - job: macOS
    pool:
      vmImage: 'macos-10.13'
      xcodeVersion: '9.4.1'
    steps:
    - bash: cd $AGENT_BUILDDIRECTORY/s/installer/macosx;chmod 777 release-build-azure.sh;./release-build-azure.sh develop
      env:
        COREHOST_TRACE: 0
        DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
        DOTNET_CLI_TELEMETRY_OPTOUT: 1
    - task: PublishBuildArtifacts@1
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)'
        # artifactName: '$AGENT_BUILDDIRECTORY/s/csoundBuildDir/CsoundOSXBinaries.zip'
