Skip to content

Commit

Permalink
[build] Added Azure DevOps & NuGet Signing (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow authored Feb 10, 2019
1 parent d077976 commit 6713ea2
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 228 deletions.
81 changes: 81 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
trigger:
- master

variables:
VERBOSITY: normal
GIT_SHA: $(Build.SourceVersion)
GIT_BRANCH_NAME: $(Build.SourceBranchName)
BUILD_NUMBER: $(Build.BuildId)
MONO_VERSION: 5_16_0
XCODE_VERSION: 10.1

jobs:
- job: build_windows
displayName: Build (Windows)
pool:
vmImage: vs2017-win2016
steps:
- powershell: .\build.ps1
- task: PublishTestResults@2
inputs:
testResultsFormat: xUnit
testResultsFiles: 'output/**/TestResult.xml'
- task: PublishPipelineArtifact@0
inputs:
artifactName: build_windows
targetPath: 'output'
- task: PublishBuildArtifacts@1
inputs:
artifactName: nuget
pathToPublish: 'output/nugets'

- job: build_macos
displayName: Build (macOS)
pool:
vmImage: macos-10.13
steps:
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'SkiaSharp iOS Certificate.p12'
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'SkiaSharp Mac Certificate.p12'
- task: InstallAppleProvisioningProfile@1
inputs:
provProfileSecureFile: 'SkiaSharp iOS Provisioning.mobileprovision'
- task: InstallAppleProvisioningProfile@1
inputs:
provProfileSecureFile: 'SkiaSharp Mac Provisioning.provisionprofile'
- task: InstallAppleProvisioningProfile@1
inputs:
provProfileSecureFile: 'SkiaSharp tvOS Provisioning.mobileprovision'
- bash: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $(MONO_VERSION)
displayName: Switch to the latest Xamarin SDK
- bash: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XCODE_VERSION).app;sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
displayName: Switch to the latest Xcode
- powershell: .\build.ps1
- task: PublishTestResults@2
inputs:
testResultsFormat: xUnit
testResultsFiles: 'output/**/TestResult.xml'
- task: PublishPipelineArtifact@0
inputs:
artifactName: build_macos
targetPath: 'output'

- job: signing
displayName: Signing NuGets
dependsOn: build_windows
pool:
name: VSEng-XamarinCustom
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'],'refs/tags/'))
steps:
- checkout: none
- template: azure-templates-sign.yml
parameters:
sourceRepo: mono/SkiaSharp.Extended
targetFolder: 'output/signed'
- task: PublishPipelineArtifact@0
inputs:
artifactName: nuget-signed
targetPath: 'output/signed'
61 changes: 61 additions & 0 deletions azure-templates-sign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
parameters:
targetFolder: ''
sourceRepo: ''
jenkinsEndpoint: '$(SIGNING_ENDPOINT)'
jenkinsJob: '$(SIGNING_JOB)'
artifactHost: '$(SIGNING_ARTIFACT_HOST)'
githubToken: '$(GITHUB_TOKEN)'

steps:

- task: JenkinsQueueJob@2
displayName: 'Request Artifact Signing'
inputs:
serverEndpoint: ${{ parameters.jenkinsEndpoint }}
jobName: ${{ parameters.jenkinsJob }}
isParameterizedJob: true
jobParameters: |
REPO=${{ parameters.sourceRepo }}
COMMIT=$(Build.SourceVersion)
JOB_ID=$(System.DefinitionId)
BUILD_ID=$(Build.BuildId)
- powershell: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Function Dump-Host {
[cmdletbinding()]
Param(
$Message,
[parameter(ValueFromPipeline)]$Data)
Process {
$_ = $Data
if ($Message) {
$Message = $ExecutionContext.InvokeCommand.ExpandString($Message)
Write-Host $Message
} else {
Write-Host $Data
}
$Data
}
}
$targetRoot = "${{ parameters.targetFolder }}"
$jobId = "${{ parameters.azureJobId }}"
$buildId = "$(Build.BuildId)"
$token = "${{ parameters.githubToken }}"
$url = "${{ parameters.artifactHost }}/$jobId-$buildId/metadata.json"
Write-Host "Getting manifest from $url"
$manifest = [string](Invoke-WebRequest -Uri $url -UseBasicParsing -Headers @{"Authorization"="token $token"}) | Dump-Host | ConvertFrom-Json
if (!(Test-Path $targetRoot -PathType Container)) {
New-Item -ItemType Directory -Force -Path $targetRoot
}
foreach ($file in $manifest) {
$fileUrl = $file.url
$fileName = [IO.Path]::GetFileName($fileUrl)
Write-Host "Downloading artifact to $targetRoot/$fileName"
Invoke-WebRequest -Uri $fileUrl -Headers @{"Authorization"="token $token"} -OutFile "$targetRoot/$fileName"
}
displayName: 'Download Signed Artifacts'
228 changes: 0 additions & 228 deletions build.groovy

This file was deleted.

2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function Pack
$dir = [System.IO.Path]::GetDirectoryName($project)
New-Item -Path "./output/$output" -ItemType Directory -Force | Out-Null
Copy-Item -Path "$dir/bin/Release" -Destination "./output/$output" -Recurse -Force
New-Item -Path "./output/nugets" -ItemType Directory -Force | Out-Null
Copy-Item -Path "$dir/bin/Release/*.nupkg" -Destination "./output/nugets/" -Recurse -Force
}

function Test
Expand Down

0 comments on commit 6713ea2

Please sign in to comment.