Skip to content

Commit

Permalink
Static YML build pipeline (#1065)
Browse files Browse the repository at this point in the history
* Templates, maestro
  • Loading branch information
j0shuams authored Dec 16, 2021
1 parent 664e218 commit d1642c8
Show file tree
Hide file tree
Showing 11 changed files with 1,180 additions and 0 deletions.
427 changes: 427 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-BuildAndTest-Stage.yml

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-Pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is used as basis for the ADO pipeline
name: $(MajorVersion).$(MinorVersion).$(PatchVersion)$(PrereleaseVersion).$(date:yyMMdd)$(rev:.r)

stages:
- template: CsWinRT-BuildAndTest-Stage.yml

- template: CsWinRT-PublishToNuget-Stage.yml

# if we are doing a release build, publish the build to Maestro
- ${{ if eq( '$(PrereleaseVersion)', '') }}:
template: CsWinRT-PublishToMaestro-Stage.yml
49 changes: 49 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-PublishToMaestro-Stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
stages:
- stage: PublishToMaestro
displayName: Trigger Maestro Publish
jobs:
- job: TriggerMaestroPublish
variables:
_DotNetCoreRuntimeVersion: 5.0.11 # matches with SDK v. 5.0.402
_WindowsSdkPackageVersion: 10.0.18362.22 # matches with one consumed in WindowsAppSdk
pool:
vmImage: windows-2019
steps:

# Parse Versions needed for offical CsWinRT version of build
- task: CmdLine@2
displayName: Parse Versions
inputs:
workingDirectory: $(Build.SourcesDirectory)
script: |
rem Parse the build-generated Build.BuildNumber into components that
rem can be recombined for version resources, nuget packages, etc.
@echo off

rem Encode the build date/rev into a 16 bit value for resource versions
if "$(PrereleaseVersion)"=="" (
set RevisionBase=30000
) else (
set RevisionBase=0
)
for /f "tokens=4,5 delims=." %%i in ("$(Build.BuildNumber)") do set BuildMetadata=%%i.%%j & set /a BuildRevision=%RevisionBase%+(((%%i/10000)-20)*366+((%%i)%%10000)/100*31+((%%i)%%100))*10+%%j

set VersionNumber=$(MajorVersion).$(MinorVersion).$(PatchVersion).%BuildRevision%

if "$(PrereleaseVersion)"=="" (
set NugetVersion=$(MajorVersion).$(MinorVersion).$(PatchVersion)
) else (
set NugetVersion=$(Build.BuildNumber)
)

rem Export generated version numbers back for subsequent tasks
echo ##vso[task.setvariable variable=BuildMetadata;]%BuildMetadata%
echo ##vso[task.setvariable variable=BuildRevision;]%BuildRevision%
echo ##vso[task.setvariable variable=VersionNumber;]%VersionNumber%
echo ##vso[task.setvariable variable=NugetVersion;]%NugetVersion%

- template: ..\..\eng\common\AzurePipelineTemplates\Maestro-PublishBuildToMaestro-Steps.yml
parameters:
AssetNames: Microsoft.Windows.CsWinRT;CsWinRT.Dependency.DotNetCoreSdk;CsWinRT.Dependency.DotNetCoreRuntime;CsWinRT.Dependency.WindowsSdkPackage
AssetVersions: $(NugetVersion);$(Net5.Sdk.Version);$(_DotNetCoreRuntimeVersion);$(_WindowsSdkPackageVersion)
261 changes: 261 additions & 0 deletions build/AzurePipelineTemplates/CsWinRT-PublishToNuget-Stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
stages:
- stage: Publish
displayName: Publish To Internal Nuget Feed Stage
jobs:
- job: PublishTo_CsWinRT_InternalFeed
pool:
vmImage: windows-2019
steps:
- checkout: self
clean: True
persistCredentials: True

# Use NuGet 5.3
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.3
continueOnError: True
inputs:
versionSpec: 5.3

# Component Detection
- task: ComponentGovernanceComponentDetection@0
displayName: Component Detection

# Download x86
- task: DownloadBuildArtifacts@0
displayName: 'Download x86 '
inputs:
artifactName: release_x86
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download x64
- task: DownloadBuildArtifacts@0
displayName: Download x64
inputs:
artifactName: release_x64
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download arm64
- task: DownloadBuildArtifacts@0
displayName: Download arm64
inputs:
artifactName: release_arm64
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download NetStandard2.0
- task: DownloadBuildArtifacts@0
displayName: Download NetStandard 2.0
inputs:
artifactName: netstandard2.0
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Download Net5.0
- task: DownloadBuildArtifacts@0
displayName: 'Download Net5.0 '
inputs:
artifactName: net5.0
itemPattern: ''
downloadPath: $(Build.SourcesDirectory)
extractTars: false

# Stage Binaries
- task: CmdLine@2
displayName: Stage Binaries
inputs:
workingDirectory: $(Build.SourcesDirectory)
script: |
copy release_x86\cswinrt.exe cswinrt.exe
copy release_x86\WinRT.Interop.winmd WinRT.Interop.winmd
# ESRP Codesigning
- task: EsrpCodeSigning@1
displayName: ESRP CodeSigning
inputs:
ConnectedServiceName: 81cc6790-027c-4ef3-928d-65e8b96a691a
FolderPath: $(Build.SourcesDirectory)
Pattern: |
cswinrt.exe
WinRT.Interop.winmd
netstandard2.0\WinRT.Runtime.dll
netstandard2.0\WinRT.Host.Shim.dll
netstandard2.0\WinRT.SourceGenerator.dll
net5.0\WinRT.Runtime.dll
net5.0\WinRT.Host.Shim.dll
release_x64\WinRT.Host.dll
release_x86\WinRT.Host.dll
release_arm64\WinRT.Host.dll
net5.0\IIDOptimizer\IIDOptimizer.exe
net5.0\IIDOptimizer\IIDOptimizer.dll
UseMinimatch: true
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-230012",
"operationSetCode": "SigntoolSign",
"parameters": [
{
"parameterName": "OpusName",
"parameterValue": "Microsoft"
},
{
"parameterName": "OpusInfo",
"parameterValue": "http://www.microsoft.com"
},
{
"parameterName": "PageHash",
"parameterValue": "/NPH"
},
{
"parameterName": "FileDigest",
"parameterValue": "/fd sha256"
},
{
"parameterName": "TimeStamp",
"parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
],
"toolName": "signtool.exe",
"toolVersion": "6.2.9304.0"
}
]
# ESRP CodeSigning 3rd Party
- task: EsrpCodeSigning@1
displayName: ESRP CodeSigning 3rd party
continueOnError: True
inputs:
ConnectedServiceName: 81cc6790-027c-4ef3-928d-65e8b96a691a
FolderPath: $(Build.SourcesDirectory)
Pattern: |
net5.0\IIDOptimizer\Mono.Cecil.dll
net5.0\IIDOptimizer\Mono.Cecil.Mdb.dll
net5.0\IIDOptimizer\Mono.Cecil.Pdb.dll
net5.0\IIDOptimizer\Mono.Cecil.Rocks.dll
UseMinimatch: true
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode" : "CP-231522",
"OperationCode" : "SigntoolSign",
"Parameters" : {
"OpusName" : "Microsoft",
"OpusInfo" : "http://www.microsoft.com",
"Append" : "/as",
"FileDigest" : "/fd \"SHA256\"",
"PageHash" : "/NPH",
"TimeStamp" : "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName" : "sign",
"ToolVersion" : "1.0"
},
{
"KeyCode" : "CP-231522",
"OperationCode" : "SigntoolVerify",
"Parameters" : {},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
# Parse Versions
- task: CmdLine@2
displayName: Parse Versions
inputs:
workingDirectory: $(Build.SourcesDirectory)
script: |
rem Parse the build-generated Build.BuildNumber into components that
rem can be recombined for version resources, nuget packages, etc.
@echo off

rem Encode the build date/rev into a 16 bit value for resource versions
if "$(PrereleaseVersion)"=="" (
set RevisionBase=30000
) else (
set RevisionBase=0
)
for /f "tokens=4,5 delims=." %%i in ("$(Build.BuildNumber)") do set BuildMetadata=%%i.%%j & set /a BuildRevision=%RevisionBase%+(((%%i/10000)-20)*366+((%%i)%%10000)/100*31+((%%i)%%100))*10+%%j

set VersionNumber=$(MajorVersion).$(MinorVersion).$(PatchVersion).%BuildRevision%

if "$(PrereleaseVersion)"=="" (
set NugetVersion=$(MajorVersion).$(MinorVersion).$(PatchVersion)
) else (
set NugetVersion=$(Build.BuildNumber)
)

rem Export generated version numbers back for subsequent tasks
echo ##vso[task.setvariable variable=BuildMetadata;]%BuildMetadata%
echo ##vso[task.setvariable variable=BuildRevision;]%BuildRevision%
echo ##vso[task.setvariable variable=VersionNumber;]%VersionNumber%
echo ##vso[task.setvariable variable=NugetVersion;]%NugetVersion%

# NuGet Pack
- task: NuGetCommand@2
displayName: NuGet pack
inputs:
command: pack
searchPatternPack: nuget/Microsoft.Windows.CsWinRT.nuspec
configurationToPack: Release
buildProperties: cswinrt_nuget_version=$(NugetVersion);cswinrt_exe=$(Build.SourcesDirectory)\cswinrt.exe;interop_winmd=$(Build.SourcesDirectory)\WinRT.Interop.winmd;netstandard2_runtime=$(Build.SourcesDirectory)\netstandard2.0\WinRT.Runtime.dll;net5_runtime=$(Build.SourcesDirectory)\net5.0\WinRT.Runtime.dll;source_generator=$(Build.SourcesDirectory)\netstandard2.0\WinRT.SourceGenerator.dll;winrt_shim=$(Build.SourcesDirectory)\net5.0\WinRT.Host.Shim.dll;winrt_host_x86=$(Build.SourcesDirectory)\release_x86\WinRT.Host.dll;winrt_host_x64=$(Build.SourcesDirectory)\release_x64\WinRT.Host.dll;winrt_host_arm64=$(Build.SourcesDirectory)\release_arm64\WinRT.Host.dll;guid_patch=$(Build.SourcesDirectory)\net5.0\IIDOptimizer\*.*

# ESRP CodeSigning
- task: EsrpCodeSigning@1
displayName: ESRP CodeSigning
inputs:
ConnectedServiceName: 81cc6790-027c-4ef3-928d-65e8b96a691a
FolderPath: $(Build.ArtifactStagingDirectory)
Pattern: '*.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"
}
]
# NuGet push
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
searchPatternPush: $(Build.ArtifactStagingDirectory)/**/*.nupkg
feedPublish: cfbb8a6b-97b7-4070-a6e8-a4081b046ae0
externalEndpoint: 80b1372e-52e9-486d-934f-92d5590c2241

# NuGet publish
- task: PublishPipelineArtifact@1
displayName: NuGet publish
inputs:
path: $(Build.ArtifactStagingDirectory)
artifactName: Publish

# Publish Symbols
- task: PublishSymbols@2
displayName: Publish Symbols
inputs:
SearchPattern: '**/*.pdb'
IndexSources: false
SymbolServerType: TeamServices
SymbolsProduct: C#/WinRT
9 changes: 9 additions & 0 deletions docs/structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This document describes the CsWinRT repository organization. Documentation and specs are located in the [`/docs`](.) folder. All source code for CsWinRT is located in the [`/src`](../src) folder, and files for generating the NuGet package are located in [`/nuget`](../nuget).

## [`build`](../build)

Contains source files for Azure DevOps pipeline that handles official builds and testing for C#/WinRT. Uses Maestro to publish builds conveniently for dependent projects; Maestro is a dependency manager
developed by dotnet as part of the [Arcade Build System](https://github.com/dotnet/arcade).

## [`eng`](../eng)

Contains files that assist with publishing to Maestro.

## [`nuget`](../nuget)

Contains source files for producing a C#/WinRT NuGet package, which is regularly built, signed, and published to nuget.org by Microsoft. The C#/WinRT NuGet package contains the **cswinrt.exe** compiler and the runtime assembly, `WinRT.Runtime.dll`.
Expand Down
Loading

0 comments on commit d1642c8

Please sign in to comment.