Skip to content

Commit e90b65b

Browse files
OneBranch Resourcesandyleejordan
authored andcommitted
Adding OneBranch pipeline YAML config file for GraphicalTools-Official
1 parent 2e566d0 commit e90b65b

9 files changed

Lines changed: 188 additions & 490 deletions

.config/tsaoptions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"instanceUrl": "https://msazure.visualstudio.com",
3+
"projectName": "One",
4+
"areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell",
5+
"notificationAliases": [ "andschwa@microsoft.com", "slee@microsoft.com" ],
6+
"codebaseName": "PowerShell_GraphicalTools_20240404",
7+
"tools": [ "CredScan", "PoliCheck", "BinSkim" ]
8+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#################################################################################
2+
# OneBranch Pipelines #
3+
# This pipeline was created by EasyStart from a sample located at: #
4+
# https://aka.ms/obpipelines/easystart/samples #
5+
# Documentation: https://aka.ms/obpipelines #
6+
# Yaml Schema: https://aka.ms/obpipelines/yaml/schema #
7+
# Retail Tasks: https://aka.ms/obpipelines/tasks #
8+
# Support: https://aka.ms/onebranchsup #
9+
#################################################################################
10+
11+
trigger: none
12+
13+
parameters:
14+
- name: debug
15+
displayName: Enable debug output
16+
type: boolean
17+
default: false
18+
19+
variables:
20+
system.debug: ${{ parameters.debug }}
21+
BuildConfiguration: Release
22+
WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2019/vse2022:latest
23+
DOTNET_NOLOGO: true
24+
DOTNET_CLI_TELEMETRY_OPTOUT: true
25+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
26+
27+
resources:
28+
repositories:
29+
- repository: templates
30+
type: git
31+
name: OneBranch.Pipelines/GovernedTemplates
32+
ref: refs/heads/main
33+
34+
extends:
35+
# https://aka.ms/obpipelines/templates
36+
template: v2/OneBranch.Official.CrossPlat.yml@templates
37+
parameters:
38+
globalSdl: # https://aka.ms/obpipelines/sdl
39+
asyncSdl:
40+
enabled: true
41+
forStages: [build]
42+
stages:
43+
- stage: build
44+
jobs:
45+
- job: main
46+
displayName: Build package
47+
pool:
48+
type: windows
49+
variables:
50+
ob_outputDirectory: $(Build.SourcesDirectory)/module
51+
steps:
52+
- pwsh: |
53+
$data = Import-PowerShellDataFile -Path src/Microsoft.PowerShell.ConsoleGuiTools/Microsoft.PowerShell.ConsoleGuiTools.psd1
54+
Write-Output "##vso[task.setvariable variable=version;isOutput=true]$($data.ModuleVersion)"
55+
name: package
56+
displayName: Get version from project properties
57+
- task: onebranch.pipeline.version@1
58+
displayName: Set OneBranch version
59+
inputs:
60+
system: Custom
61+
customVersion: $(package.version)
62+
- task: UseDotNet@2
63+
displayName: Use .NET 6.x SDK
64+
inputs:
65+
packageType: sdk
66+
version: 6.x
67+
- task: PowerShell@2
68+
displayName: Install PSResources
69+
inputs:
70+
pwsh: true
71+
filePath: tools/installPSResources.ps1
72+
- pwsh: Invoke-Build -Configuration $(BuildConfiguration)
73+
displayName: Build
74+
- task: onebranch.pipeline.signing@1
75+
displayName: Sign 1st-party files
76+
inputs:
77+
command: sign
78+
signing_environment: external_distribution
79+
search_root: $(Build.SourcesDirectory)/module
80+
files_to_sign: |
81+
**/*.psd1;
82+
**/Microsoft.PowerShell.*.dll;
83+
- task: onebranch.pipeline.signing@1
84+
displayName: Sign 3rd-party files
85+
inputs:
86+
command: sign
87+
signing_environment: 135020002
88+
search_root: $(Build.SourcesDirectory)/module
89+
files_to_sign: |
90+
**/NStack.dll;
91+
**/Terminal.Gui.dll;
92+
- stage: release
93+
dependsOn: build
94+
variables:
95+
version: $[ stageDependencies.build.main.outputs['package.version'] ]
96+
drop: $(Pipeline.Workspace)/drop_build_main
97+
jobs:
98+
- job: github
99+
displayName: Publish draft to GitHub
100+
pool:
101+
type: windows
102+
variables:
103+
ob_outputDirectory: $(Build.SourcesDirectory)/out
104+
steps:
105+
- download: current
106+
displayName: Download artifacts
107+
- task: ArchiveFiles@2
108+
displayName: Zip signed artifacts
109+
inputs:
110+
rootFolderOrFile: $(drop)
111+
includeRootFolder: false
112+
archiveType: zip
113+
archiveFile: out/GraphicalTools.zip
114+
- task: GitHubRelease@1
115+
displayName: Create GitHub release
116+
inputs:
117+
gitHubConnection: GitHub
118+
repositoryName: PowerShell/GraphicalTools
119+
assets: out/GraphicalTools.zip
120+
tagSource: userSpecifiedTag
121+
tag: v$(version)
122+
isDraft: true
123+
addChangeLog: false
124+
releaseNotesSource: inline
125+
releaseNotesInline: "<!-- TODO: Generate release notes on GitHub! -->"
126+
- job: validation
127+
displayName: Manual validation
128+
pool:
129+
type: agentless
130+
timeoutInMinutes: 1440
131+
steps:
132+
- task: ManualValidation@0
133+
displayName: Wait 24 hours for validation
134+
inputs:
135+
notifyUsers: $(Build.RequestedForEmail)
136+
instructions: Please validate the release and then publish it!
137+
timeoutInMinutes: 1440
138+
- pwsh: |
139+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
140+
Install-Module -Name Microsoft.PowerShell.PSResourceGet -AllowPrerelease -Scope CurrentUser -Force
141+
Import-Module -Name Microsoft.PowerShell.PSResourceGet -MinimumVersion 1.0.0
142+
Publish-PSResource -Path $(Pipeline.Workspace)/Publish/Microsoft.PowerShell.ConsoleGuiTools -Repository PSGallery -APIKey $(GalleryToken) -Verbose
143+
dependsOn: validation
144+
displayName: Publishing ConsoleGuiTools to PowerShell Gallery

GraphicalTools.build.ps1

Lines changed: 12 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,29 @@ param(
66
[string[]]$ModuleName = @("Microsoft.PowerShell.ConsoleGuiTools" )
77
)
88

9-
$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows
10-
119
$script:TargetFramework = "net6.0"
12-
$script:RequiredSdkVersion = (Get-Content (Join-Path $PSScriptRoot 'global.json') | ConvertFrom-Json).sdk.version
1310

1411
$script:ModuleLayouts = @{}
1512
foreach ($mn in $ModuleName) {
1613
$script:ModuleLayouts.$mn = Import-PowerShellDataFile -Path "$PSScriptRoot/src/$mn/ModuleLayout.psd1"
1714
}
1815

19-
task SetupDotNet -Before Clean, Build {
20-
21-
$dotnetPath = "$PSScriptRoot/.dotnet"
22-
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
23-
$originalDotNetExePath = $dotnetExePath
24-
25-
if (!(Test-Path $dotnetExePath)) {
26-
$installedDotnet = Get-Command dotnet -ErrorAction Ignore
27-
if ($installedDotnet) {
28-
$dotnetExePath = $installedDotnet.Source
29-
}
30-
else {
31-
$dotnetExePath = $null
32-
}
33-
}
34-
35-
# Make sure the dotnet we found is the right version
36-
if ($dotnetExePath) {
37-
# dotnet --version can write to stderr, which causes builds to abort, therefore use --list-sdks instead.
38-
if ((& $dotnetExePath --list-sdks | ForEach-Object { $_.Split()[0] } ) -contains $script:RequiredSdkVersion) {
39-
$script:dotnetExe = $dotnetExePath
40-
}
41-
else {
42-
# Clear the path so that we invoke installation
43-
$script:dotnetExe = $null
44-
}
45-
}
46-
else {
47-
# Clear the path so that we invoke installation
48-
$script:dotnetExe = $null
49-
}
50-
51-
if ($script:dotnetExe -eq $null) {
52-
53-
Write-Host "`n### Installing .NET CLI $script:RequiredSdkVersion...`n" -ForegroundColor Green
16+
task FindDotNet -Before Clean, Build {
17+
Assert (Get-Command dotnet -ErrorAction SilentlyContinue) "dotnet not found, please install it: https://aka.ms/dotnet-cli"
5418

55-
# The install script is platform-specific
56-
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" }
19+
# Strip out semantic version metadata so it can be cast to `Version`
20+
[Version]$existingVersion, $null = (dotnet --version) -split " " -split "-"
21+
Assert ($existingVersion -ge [Version]("6.0")) ".NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
5722

58-
# Download the official installation script and run it
59-
$installScriptPath = "$([System.IO.Path]::GetTempPath())dotnet-install.$installScriptExt"
60-
Invoke-WebRequest "https://dot.net/v1/dotnet-install.$installScriptExt" -OutFile $installScriptPath
61-
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet"
62-
63-
if (!$script:IsUnix) {
64-
& $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
65-
}
66-
else {
67-
& /bin/bash $installScriptPath -Version $script:RequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
68-
$env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH
69-
}
70-
71-
Write-Host "`n### Installation complete." -ForegroundColor Green
72-
$script:dotnetExe = $originalDotnetExePath
73-
}
74-
75-
# This variable is used internally by 'dotnet' to know where it's installed
76-
$script:dotnetExe = Resolve-Path $script:dotnetExe
77-
if (!$env:DOTNET_INSTALL_DIR) {
78-
$dotnetExeDir = [System.IO.Path]::GetDirectoryName($script:dotnetExe)
79-
$env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH
80-
$env:DOTNET_INSTALL_DIR = $dotnetExeDir
81-
}
82-
83-
Write-Host "`n### Using dotnet v$(& $script:dotnetExe --version) at path $script:dotnetExe`n" -ForegroundColor Green
23+
Write-Host "Using dotnet v$(dotnet --version) at path $((Get-Command dotnet).Source)" -ForegroundColor Green
8424
}
8525

8626
task Build {
8727
Remove-Item $PSScriptRoot/module -Recurse -Force -ErrorAction Ignore
8828

8929
foreach ($moduleLayout in $script:ModuleLayouts.Values) {
9030
foreach ($projName in $moduleLayout.RequiredBuildAssets.Keys) {
91-
exec { & $script:dotnetExe publish -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
31+
exec { & dotnet publish -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
9232
}
9333

9434
foreach ($nativeProj in $moduleLayout.NativeBuildAssets.Keys) {
@@ -99,29 +39,24 @@ task Build {
9939
else {
10040
"/property:IsWindows=false"
10141
}
102-
exec { & $script:dotnetExe publish -c $Configuration "$PSScriptRoot/src/$nativeProj/$nativeProj.csproj" -r $targetPlatform $buildPropertyParams }
42+
exec { & dotnet publish -c $Configuration "$PSScriptRoot/src/$nativeProj/$nativeProj.csproj" -r $targetPlatform $buildPropertyParams }
10343
}
10444
}
10545
}
10646
}
10747

10848
task Clean {
109-
#Remove Module Build
110-
Remove-Item $PSScriptRoot/module -Recurse -Force -ErrorAction Ignore
49+
Remove-BuildItem $PSScriptRoot/module
11150

11251
foreach ($moduleLayout in $script:ModuleLayouts.Values) {
11352
foreach ($projName in $moduleLayout.RequiredBuildAssets.Keys) {
114-
exec { & $script:dotnetExe clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
53+
exec { & dotnet clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
11554
}
11655

11756
foreach ($projName in $moduleLayout.NativeBuildAssets.Keys) {
118-
exec { & $script:dotnetExe clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
57+
exec { & dotnet clean -c $Configuration "$PSScriptRoot/src/$projName/$projName.csproj" }
11958
}
12059
}
121-
122-
foreach ($mn in $ModuleName) {
123-
Get-ChildItem "$PSScriptRoot\module\$mn\Commands\en-US\*-help.xml" -ErrorAction Ignore | Remove-Item -Force
124-
}
12560
}
12661

12762
task LayoutModule -After Build {
@@ -132,7 +67,7 @@ task LayoutModule -After Build {
13267
# Create the destination dir
13368
$null = New-Item -Force $moduleBinPath -Type Directory
13469

135-
# For each PSES subproject
70+
# For each subproject
13671
foreach ($projectName in $moduleLayout.RequiredBuildAssets.Keys) {
13772
# Get the project build dir path
13873
$basePath = [System.IO.Path]::Combine($PSScriptRoot, 'src', $projectName, 'bin', $Configuration, $script:TargetFramework)

NuGet.config

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<packageSources>
4-
<clear />
5-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6-
</packageSources>
7-
<disabledPackageSources>
8-
<clear />
9-
</disabledPackageSources>
3+
<packageSources>
4+
<clear />
5+
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/mscodehub/PowerShellCore/_packaging/PowerShellCore_PublicPackages/nuget/v3/index.json" />
6+
</packageSources>
107
</configuration>

global.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"sdk": {
3-
"version": "6.0.416"
3+
"version": "6.0.420",
4+
"rollForward": "latestFeature",
5+
"allowPrerelease": false
46
}
5-
}
7+
}
8+
9+

tools/azurePipelinesBuild.ps1

Lines changed: 0 additions & 12 deletions
This file was deleted.

tools/installPSResources.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
$ErrorActionPreference = 'Stop'
5+
6+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
7+
if ($PSVersionTable.PSVersion.Major -lt 6) {
8+
throw "The build script requires PowerShell 7!"
9+
}
10+
11+
# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4
12+
Install-Module -Name InvokeBuild -Scope CurrentUser
13+
Install-Module -Name platyPS -Scope CurrentUser

0 commit comments

Comments
 (0)