Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor official release pipeline #48

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 7 additions & 169 deletions pipelines/productionBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,184 +15,22 @@ pool:
- vstest

variables:
buildPlatform: "Any CPU"
buildConfiguration: "Release"
ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.Graph.Bicep.Types\bin\$(BuildConfiguration)'
- template: ./common-variables.yml

stages:
- stage: build
jobs:
- job: build

steps:
- task: UseDotNet@2
displayName: "Use .NET 2" # needed for ESRP signing
inputs:
version: 2.x

- task: UseDotNet@2
displayName: "Use .NET 6"
inputs:
version: 6.x

- task: PoliCheck@1
displayName: 'Run PoliCheck "/src"'
inputs:
inputType: CmdLine
cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml'

# Install the nuget tool.
- task: NuGetToolInstaller@0
displayName: "Use NuGet >=5.2.0"
inputs:
versionSpec: ">=5.2.0"
checkLatest: true

# Build the solution
- task: DotNetCoreCLI@2
displayName: "build"
inputs:
projects: '$(Build.SourcesDirectory)\Microsoft.Graph.Bicep.Types.sln'
arguments: "--configuration $(BuildConfiguration) --no-incremental"

# Run unit tests
- task: DotNetCoreCLI@2
displayName: "test"
inputs:
command: "test"
projects: '$(Build.SourcesDirectory)\Microsoft.Graph.Bicep.Types.sln'
arguments: "--configuration $(BuildConfiguration) --no-build"

# CredScan
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
displayName: "Run CredScan - Src"
inputs:
toolMajorVersion: "V2"
scanFolder: '$(Build.SourcesDirectory)\src'
debugMode: false

- task: AntiMalware@3
displayName: "Run MpCmdRun.exe - ProductBinPath"
inputs:
FileDirPath: "$(ProductBinPath)"
enabled: false

- task: BinSkim@3
displayName: "Run BinSkim - Product Binaries"
inputs:
InputType: Basic
AnalyzeTarget: '$(ProductBinPath)\**\Microsoft.Graph.Bicep.Types.dll'
AnalyzeSymPath: "$(ProductBinPath)"
AnalyzeVerbose: true
AnalyzeHashes: true
AnalyzeEnvironment: true

- task: PublishSecurityAnalysisLogs@2
displayName: "Publish Security Analysis Logs"
inputs:
ArtifactName: SecurityLogs

- task: PostAnalysis@1
displayName: "Post Analysis"
inputs:
BinSkim: true
CredScan: true
PoliCheck: true

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: "ESRP CodeSigning"
inputs:
ConnectedServiceName: "microsoftgraph ESRP CodeSign DLL and NuGet (AKV)"
FolderPath: src
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "Microsoft"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://www.microsoft.com"
},
{
"parameterName": "FileDigest",
"parameterValue": "/fd \"SHA256\""
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20

# Pack
- task: DotNetCoreCLI@2
displayName: "pack"
inputs:
command: pack
projects: src/Microsoft.Graph.Bicep.Types/Microsoft.Graph.Bicep.Types.csproj
arguments: "-o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg"
- template: ./common-templates/install-tools.yml

- task: PowerShell@2
displayName: "Validate project version has been incremented"
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/main'), succeeded())
enabled: false
inputs:
targetType: "filePath"
filePath: $(System.DefaultWorkingDirectory)\scripts\ValidateProjectVersionUpdated.ps1
pwsh: true
- template: ./common-templates/security-pre-checks.yml

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: "ESRP CodeSigning Nuget Packages"
inputs:
ConnectedServiceName: "microsoftgraph ESRP CodeSign DLL and NuGet (AKV)"
FolderPath: "$(Build.ArtifactStagingDirectory)"
Pattern: "*.nupkg"
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
SessionTimeout: 20
- template: ./common-templates/common-steps.yml
parameters:
Official: true

- task: PublishPipelineArtifact@1
displayName: "Upload Artifact: Nugets"
inputs:
artifactName: Nugets
targetPath: $(Build.ArtifactStagingDirectory)
- template: ./common-templates/security-post-checks.yml

- stage: deploy
condition: and(contains(variables['build.sourceBranch'], 'refs/heads/main'), succeeded())
Expand Down