azure-functions-rabbitmq-ex.../azure-pipelines.yml

254 строки
10 KiB
YAML

pr:
branches:
include:
- dev
- v*.x
schedules:
- cron: '0 12 * * 0'
displayName: Weekly Sunday build
branches:
include:
- dev
always: true
trigger:
branches:
include:
- dev
- v*.x
tags:
include:
- v*.*.*
variables:
# It is a release build if it is triggered by pushing a tag.
isReleaseBuild: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}
${{ if eq(variables.isReleaseBuild, 'True') }}:
agentOSes: Windows
${{ else }}:
agentOSes: Windows,Linux
prefix: $[format('0.{0:yyyy}.{0:MMdd}', pipeline.startTime)]
version: $[format('{0}.{1}', variables.prefix, counter(variables.prefix, 1))] # e.g. 0.2001.0203.4
fileVersion: $[variables.version]
Codeql.Enabled: true
jobs:
- ${{ each agentOS in split(variables.agentOSes, ',') }}:
- job: buildExtension${{ agentOS }}
displayName: WebJobs Extension (${{ agentOS }})
pool:
${{ if eq(variables.isReleaseBuild, 'True') }}:
name: 1ES-Hosted-AzFunc
demands:
- ImageOverride -equals MMS2022TLS
${{ elseif eq(agentOS, 'Windows') }}:
vmImage: windows-latest
${{ elseif eq(agentOS, 'Linux') }}:
vmImage: ubuntu-latest
steps:
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: | # Allow tags matching v1.2.3 and v1.2.3-xyz1
$found = '$(Build.SourceBranchName)' | Select-String -Pattern '^v(((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:-\w+)?)$'
if (-not $found) {
Write-Error "Found unexpected tag name: $(Build.SourceBranchName)."
exit 1
}
Write-Host "##vso[task.setvariable variable=version]$($found.Matches.Groups[1].Value)"
Write-Host "##vso[task.setvariable variable=fileVersion]$($found.Matches.Groups[2].Value)"
displayName: Extract version # e.g. 1.2.3
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
# .NET Core 2.1 SDK is required by ESRP Code Signing tasks.
- task: UseDotNet@2
displayName: Acquire .NET Core 2.1 SDK
inputs:
packageType: sdk
version: 2.1.x
performMultiLevelLookup: true
- task: UseDotNet@2
displayName: Acquire .NET 7.0 SDK
inputs:
packageType: sdk
version: 7.0.x
performMultiLevelLookup: true
- task: DotNetCoreCLI@2
displayName: Build solution
inputs:
command: build
workingDirectory: extension
arguments: --configuration Release -property:Version=$(fileVersion) -property:CommitHash=$(Build.SourceVersion)
- task: DotNetCoreCLI@2
displayName: Test extension
inputs:
command: test
workingDirectory: extension
arguments: --configuration Debug
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: EsrpCodeSigning@1
displayName: Sign extension assembly
inputs:
connectedServiceName: ESRP Service
folderPath: extension/WebJobs.Extensions.RabbitMQ/bin/Release/netstandard2.0
pattern: Microsoft.Azure.WebJobs.Extensions.RabbitMQ.dll
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "http://www.microsoft.com",
"FileDigest": "/fd \"SHA256\"",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: DotNetCoreCLI@2
displayName: Pack extension
inputs:
command: pack
searchPatternPack: extension/WebJobs.Extensions.RabbitMQ/WebJobs.Extensions.RabbitMQ.csproj
configurationToPack: Release
buildProperties: Version=$(version);CommitHash=$(Build.SourceVersion)
outputDir: $(Build.ArtifactStagingDirectory)/$(version)
nobuild: true
includesymbols: true
verbosityPack: minimal
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: EsrpCodeSigning@1
displayName: Sign extension package
inputs:
connectedServiceName: ESRP Service
folderPath: $(Build.ArtifactStagingDirectory)/$(version)
pattern: Microsoft.Azure.WebJobs.Extensions.RabbitMQ.*.nupkg
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: DeleteFiles@1
displayName: Cleanup staging directory
inputs:
sourceFolder: $(Build.ArtifactStagingDirectory)/$(version)
# contents: '!(Microsoft.Azure.WebJobs.Extensions.RabbitMQ.*.nupkg)'
contents: CodeSignSummary-*.md
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: ManifestGeneratorTask@0
displayName: Generate SBOM manifest
inputs:
buildDropPath: $(Build.ArtifactStagingDirectory)/$(version)
packageName: Azure Functions RabbitMQ Extension
packageVersion: $(version)
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- publish: $(Build.ArtifactStagingDirectory)
displayName: Publish extension package
artifact: drop-extension
- job: buildJavaLibrary${{ agentOS }}
displayName: Java Library (${{ agentOS }})
pool:
${{ if eq(variables.isReleaseBuild, 'True') }}:
name: 1ES-Hosted-AzFunc
demands:
- ImageOverride -equals MMS2022TLS
${{ elseif eq(agentOS, 'Windows') }}:
vmImage: windows-latest
${{ elseif eq(agentOS, 'Linux') }}:
vmImage: ubuntu-latest
steps:
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: | # Allow tags matching v1.2.3 and v1.2.3-xyz1
$found = '$(Build.SourceBranchName)' | Select-String -Pattern '^v((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-\w+)?)$'
if (-not $found) {
Write-Error "Found unexpected tag name: $(Build.SourceBranchName)."
exit 1
}
Write-Host "##vso[task.setvariable variable=version]$($found.Matches.Groups[1].Value)"
displayName: Extract version # e.g. 1.2.3
# A combination of --batch-mode and --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
# options prevents spurious logging about downloading of Maven packages.
- task: Maven@3
displayName: Set library version
inputs:
mavenPomFile: java-library/pom.xml
goals: versions:set
options: --batch-mode --define=newVersion=$(version) --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
- task: Maven@3
displayName: Build library
inputs:
mavenPomFile: java-library/pom.xml
options: --batch-mode --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: |
$prefix = 'azure-functions-java-library-rabbitmq-$(version)'
$source = 'java-library'
$destination = '$(Build.ArtifactStagingDirectory)/$(version)'
New-Item $destination -ItemType Directory
Copy-Item "$source/pom.xml" "$destination/$prefix.pom"
Copy-Item "$source/target/$prefix.jar" "$destination/$prefix.jar"
Copy-Item "$source/target/$prefix-javadoc.jar" "$destination/$prefix-javadoc.jar"
Copy-Item "$source/target/$prefix-sources.jar" "$destination/$prefix-sources.jar"
displayName: Copy output files
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: ManifestGeneratorTask@0
displayName: Generate SBOM manifest
inputs:
buildDropPath: $(Build.ArtifactStagingDirectory)/$(version)
packageName: Azure Functions RabbitMQ Java Bindings
packageVersion: $(version)
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- publish: $(Build.ArtifactStagingDirectory)
displayName: Publish library package
artifact: drop-java-library