Skip to content

Commit

Permalink
Azure pipeline to generate and publish Microsoft.WindowsPackageManage…
Browse files Browse the repository at this point in the history
…r.Utils nuget package (microsoft#741)
  • Loading branch information
palenshus authored Feb 8, 2021
1 parent 3a94abd commit 2a6095c
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ ENU
enum
errorlevel
errstr
esrp
etag
ETW
EVENTTAG
Expand Down Expand Up @@ -193,6 +194,7 @@ mday
metadata
microsoft
mimetype
Minimatch
MINORVERSION
monostate
motw
Expand Down Expand Up @@ -232,6 +234,8 @@ NTSTATUS
nuget
nullptr
nullsoft
nupkg
nuspec
nunit
OAuth
ofstream
Expand All @@ -242,6 +246,7 @@ ostringstream
OSVERSIONINFOEXW
outfile
OUTOFMEMORY
Params
parentidx
pathpart
Pathto
Expand Down Expand Up @@ -295,6 +300,7 @@ rowcount
rowid
rubengustorage
runsettings
runtimes
safecast
savepoint
SCROLLER
Expand Down
10 changes: 10 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ El proyecto .* diferentes
\b[-.A-Za-z0-9]+_[a-z0-9]{13}\b
# Locales for name normalization
\b\p{Lu}{2,3}(?:-(?:CANS|CYRL|LATN|MONG))?-\p{Lu}{2}(?![A-Z])(?:-VALENCIA)?\b
# Azure pipeline tasks
- task: .*

# Slash-prefixed patterns
\\native(?![a-z])
/NPH(?![a-z])
/td(?![a-z])

# URLs -- Added here instead of allow.txt to facilitate wildcarding them as more are added
http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer
20 changes: 20 additions & 0 deletions WinGetUtil.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Microsoft.WindowsPackageManager.Utils</id>
<version>$version$</version>
<title></title>
<authors>Microsoft</authors>
<owners></owners>
<projectUrl>https://github.com/microsoft/winget-cli</projectUrl>
<license type="expression">MIT</license>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>The utility binary for use with the WinGet CLI.</description>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<tags>winget</tags>
</metadata>
<files>
<file src="src\x64\Release\WinGetUtil\WinGetUtil.dll" target="runtimes\win-x64\native\WinGetUtil.dll"/>
<file src="src\x86\Release\WinGetUtil\WinGetUtil.dll" target="runtimes\win-x86\native\WinGetUtil.dll"/>
</files>
</package>
143 changes: 143 additions & 0 deletions azure-pipelines.nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
trigger: none

parameters:
- name: version
displayName: Version to stamp on binaries and nuget package. Should be in form of "major.minor", for example "1.0"
type: string

pool:
vmImage: "windows-latest"

variables:
solution: "src/AppInstallerCLI.sln"
buildConfiguration: "Release"
packageName: Microsoft.WindowsPackageManager.Utils

jobs:
- job: "Build"
variables:
BuildVer: $[counter(${{ parameters.version }}, 1)]
version: ${{ parameters.version }}.$(BuildVer)
steps:
- script: echo $(version)

- task: NuGetToolInstaller@1
displayName: Install Nuget

# Restores all projects, including native (vcxproj) projects
- task: NuGetCommand@2
displayName: Restore Packages
inputs:
restoreSolution: "$(solution)"

# Restores only .NET core projects, but is still necessary, as without this the IndexCreationTool and LocalhostWebServer projects fail to build
- task: DotNetCoreCLI@2
displayName: DotNet Restore
inputs:
command: "restore"
projects: "**/*.csproj"

- task: PowerShell@2
displayName: Update Binary Version
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
inputs:
filePath: 'src\binver\Update-BinVer.ps1'
arguments: '-TargetFile binver\binver\version.h -BuildVersion $(BuildVer) -MajorMinorOverride ${{ parameters.version }}'
workingDirectory: "src"

- task: VSBuild@1
displayName: Build Solution x86
inputs:
platform: "x86"
solution: "$(solution)"
configuration: "$(buildConfiguration)"

- task: VSBuild@1
displayName: Build Solution x64
inputs:
platform: "x64"
solution: "$(solution)"
configuration: "$(buildConfiguration)"

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: "ESRP CodeSigning - Package contents"
inputs:
ConnectedServiceName: "WindowsPackageManager ESRP CodeSigning"
FolderPath: src
Pattern: |
*\$(buildConfiguration)\WinGetUtil\WinGetUtil.dll
UseMinimatch: true
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"
}
]
- task: NuGetCommand@2
displayName: Pack WingetUtil nuget package
inputs:
command: pack
packagesToPack: WinGetUtil.nuspec
versioningScheme: byEnvVar
versionEnvVar: version
packDestination: "$(Build.ArtifactStagingDirectory)"

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: "ESRP CodeSigning - NuGet package"
inputs:
ConnectedServiceName: "WindowsPackageManager ESRP CodeSigning"
FolderPath: "$(Build.ArtifactStagingDirectory)"
Pattern: "Microsoft.Packaging.WinGetUtil.$(version).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"
}
]
- task: PublishBuildArtifacts@1
displayName: Publish nuget package to artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\$(packageName).$(version).nupkg'
ArtifactName: $(packageName)
publishLocation: Container

- task: NuGetCommand@2
displayName: Push WingetUtil nuget package to nuget.org
inputs:
command: push
nuGetFeedType: external
includeNugetOrg: true
packagesToPush: '$(Build.ArtifactStagingDirectory)\$(packageName).$(version).nupkg'
publishFeedCredentials: "WindowsPackageManagerAzurePipelineNuget - NuGet.org"
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ jobs:
- task: NuGetToolInstaller@1
displayName: Install Nuget

# Restores all projects, including native (vcxproj) projects
- task: NuGetCommand@2
displayName: Restore Packages
inputs:
restoreSolution: '$(solution)'

# Restores only .NET core projects, but is still necessary, as without this the IndexCreationTool and LocalhostWebServer projects fail to build
- task: DotNetCoreCLI@2
displayName: DotNet Restore
inputs:
Expand Down
29 changes: 20 additions & 9 deletions src/binver/Update-BinVer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,36 @@ param(
[Parameter(Mandatory=$false)]
[int]$BuildVersion = 0,

[Parameter(Mandatory=$false)]
[string]$MajorMinorOverride,

[switch]$OutVar
)

$ErrorActionPreference = 'SilentlyContinue'
$Local:GitDescribeText = git describe --tags;
$ErrorActionPreference = 'Continue'
Write-Host "Git describe: $Local:GitDescribeText"

$Local:Major = 0;
$Local:Minor = 0;

if ($Local:GitDescribeText -match "v([0-9]+)\.([0-9]+)")
if ($MajorMinorOverride -match "([0-9]+)\.([0-9]+)")
{
$Local:Major = $Matches[1]
$Local:Minor = $Matches[2]
}
else
{
Write-Host "Describe did not match regex; using zeros"
else {
$ErrorActionPreference = 'SilentlyContinue'
$Local:GitDescribeText = git describe --tags;
$ErrorActionPreference = 'Continue'

Write-Host "Git describe: $Local:GitDescribeText"

if ($Local:GitDescribeText -match "v([0-9]+)\.([0-9]+)")
{
$Local:Major = $Matches[1]
$Local:Minor = $Matches[2]
}
else
{
Write-Host "Describe did not match regex and major/minor weren't explicitly provided; using zeros"
}
}

Write-Host "Using version: $Local:Major.$Local:Minor.$BuildVersion"
Expand Down

0 comments on commit 2a6095c

Please sign in to comment.