Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 55e04ad

Browse files
authored
changes required for OneBranch pipelines (#45)
* Initial code for OneBranch build and gallery publish. * put codebaseName back into tsaoptions. Fix output folder and remove extraneous files. * Add some debugging. explicitly call for a release build. * reduce debug output. * remove vso upload directive from build.ps1
1 parent ad78ef8 commit 55e04ad

File tree

5 files changed

+171
-10
lines changed

5 files changed

+171
-10
lines changed

.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+
"codebaseName": "TFSMSAzure_TextUtility",
6+
"notificationAliases": [ "[email protected]", "[email protected]" ],
7+
"tools": [ "CredScan", "PoliCheck", "BinSkim" ]
8+
}

.pipelines/TextUtility-Official.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: TextUtility-ModuleBuild-$(Build.BuildId)
2+
trigger: none
3+
pr: none
4+
5+
variables:
6+
BuildConfiguration: Release
7+
DOTNET_NOLOGO: true
8+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
9+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
10+
POWERSHELL_TELEMETRY_OPTOUT: 1
11+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
12+
WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest
13+
14+
resources:
15+
repositories:
16+
- repository: templates
17+
type: git
18+
name: OneBranch.Pipelines/GovernedTemplates
19+
ref: refs/heads/main
20+
21+
extends:
22+
# https://aka.ms/obpipelines/templates
23+
template: v2/OneBranch.Official.CrossPlat.yml@templates
24+
parameters:
25+
featureFlags:
26+
WindowsHostVersion: '1ESWindows2022'
27+
globalSdl: # https://aka.ms/obpipelines/sdl
28+
asyncSdl:
29+
enabled: true
30+
forStages: [build]
31+
#credscan:
32+
# enabled: true
33+
# scanfolder: $(Build.SourcesDirectory)
34+
# suppressionsFile: $(Build.SourcesDirectory)\.config\suppress.json
35+
stages:
36+
- stage: build
37+
jobs:
38+
- job: main
39+
displayName: Build package
40+
pool:
41+
type: windows
42+
variables:
43+
- name: ob_outputDirectory
44+
value: $(Build.SourcesDirectory)/out
45+
#- name: ob_sdl_credscan_suppressionsFile
46+
# value: $(Build.SourcesDirectory)\.config\suppress.json
47+
steps:
48+
- pwsh: |
49+
Write-Verbose -Verbose ((Get-Item $(Build.SourcesDirectory)).FullName)
50+
Get-ChildItem $(Build.SourcesDirectory) -Recurse -File -Name | Write-Verbose -Verbose
51+
$manifestData = Import-PowerShellDataFile -Path src/Microsoft.PowerShell.TextUtility.psd1
52+
$moduleVersion = $manifestData.ModuleVersion
53+
Write-Output "##vso[task.setvariable variable=version;isOutput=true]$moduleVersion"
54+
if ($manifestData.PrivateData.PsData.Prerelease) {
55+
$prerel = $manifestData.PrivateData.PSData.Prerelease
56+
$nupkgVersion = "${moduleVersion}-${prerel}"
57+
} else {
58+
$nupkgVersion = $moduleVersion
59+
}
60+
Write-Output "##vso[task.setvariable variable=nupkgversion;isOutput=true]$nupkgVersion"
61+
name: package
62+
displayName: Get version from project properties
63+
- task: onebranch.pipeline.version@1
64+
displayName: Set OneBranch version
65+
inputs:
66+
system: Custom
67+
customVersion: $(package.version)
68+
- task: UseDotNet@2
69+
displayName: Use .NET SDK
70+
inputs:
71+
packageType: sdk
72+
useGlobalJson: true
73+
- pwsh: |
74+
Get-ChildItem | Write-Verbose -Verbose
75+
./build.ps1 -Configuration Release
76+
displayName: Build
77+
- task: onebranch.pipeline.signing@1
78+
displayName: Sign 1st-party files
79+
inputs:
80+
command: sign
81+
signing_profile: external_distribution
82+
search_root: $(Build.SourcesDirectory)/out/Microsoft.PowerShell.TextUtility
83+
files_to_sign: |
84+
*.psd1;
85+
*.ps1xml;
86+
Microsoft.PowerShell.*.dll;
87+
- task: ArchiveFiles@2
88+
displayName: Zip module
89+
inputs:
90+
rootFolderOrFile: $(Build.SourcesDirectory)/out/Microsoft.PowerShell.TextUtility
91+
includeRootFolder: false
92+
archiveType: zip
93+
archiveFile: out/Microsoft.PowerShell.TextUtility-v$(package.version).zip
94+
- pwsh: |
95+
./build -package -nobuild
96+
Write-Verbose -Verbose ((Get-Item .).FullName)
97+
Write-Verbose -Verbose ((Get-Item $(Build.SourcesDirectory)).FullName)
98+
Get-ChildItem $(Build.SourcesDirectory) -Recurse -File -Name | Write-Verbose -Verbose
99+
displayName: Package module
100+
- task: onebranch.pipeline.signing@1
101+
displayName: Sign NuGet package
102+
inputs:
103+
command: sign
104+
signing_profile: external_distribution
105+
search_root: $(Build.SourcesDirectory)
106+
files_to_sign: "**/*.nupkg"
107+
- stage: release
108+
dependsOn: build
109+
variables:
110+
version: $[ stageDependencies.build.main.outputs['package.version'] ]
111+
drop: $(Pipeline.Workspace)/drop_build_main
112+
jobs:
113+
- job: validation
114+
displayName: Manual validation
115+
pool:
116+
type: agentless
117+
timeoutInMinutes: 1440
118+
steps:
119+
- task: ManualValidation@0
120+
displayName: Wait 24 hours for validation
121+
inputs:
122+
notifyUsers: $(Build.RequestedForEmail)
123+
instructions: Please validate the release and then publish it!
124+
timeoutInMinutes: 1440
125+
- job: publish
126+
dependsOn: validation
127+
displayName: Publish to PowerShell Gallery
128+
pool:
129+
type: windows
130+
variables:
131+
ob_outputDirectory: $(Build.SourcesDirectory)/out/Microsoft.PowerShell.TextUtility
132+
steps:
133+
- download: current
134+
displayName: Download artifacts
135+
- task: NuGetCommand@2
136+
displayName: Publish ConsoleGuiTools to PowerShell Gallery
137+
inputs:
138+
command: push
139+
packagesToPush: $(Build.SourcesDirectory)/out/Microsoft.PowerShell.TextUtility.$(package.nupkgVersion).nupkg
140+
nuGetFeedType: external
141+
publishFeedCredentials: PowerShellGallery

build.ps1

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function Export-Module
6464
# now construct a nupkg by registering a local repository and calling publish module
6565
$repoName = [guid]::newGuid().ToString("N")
6666
try {
67-
Register-PSRepository -Name $repoName -SourceLocation ${repoRoot} -InstallationPolicy Trusted
67+
Register-PSRepository -Name $repoName -SourceLocation "${repoRoot}/out" -InstallationPolicy Trusted
6868
Publish-Module -Path $packageRoot -Repository $repoName
6969
}
7070
catch {
@@ -82,14 +82,8 @@ function Export-Module
8282
$pre = $moduleInfo.PrivateData.PSData.Prerelease
8383
if ($pre) { $nupkgName += "-${pre}" }
8484
$nupkgName += ".nupkg"
85-
$nupkgPath = Join-Path $repoRoot $nupkgName
86-
if ($env:TF_BUILD) {
87-
# In Azure DevOps
88-
Write-Host "##vso[artifact.upload containerfolder=$nupkgName;artifactname=$nupkgName;]$nupkgPath"
89-
}
90-
else {
91-
Write-Verbose -Verbose "package path: ${nupkgPath} (exists:$(Test-Path $nupkgPath))"
92-
}
85+
$nupkgPath = Join-Path $repoRoot out $nupkgName
86+
Write-Verbose -Verbose "package path: ${nupkgPath} (exists:$(Test-Path $nupkgPath))"
9387
}
9488

9589
function Test-Module {
@@ -129,7 +123,11 @@ try {
129123
}
130124

131125
if (-not $NoBuild) {
132-
dotnet publish --output $outPath --configuration $Configuration
126+
dotnet publish --verbosity d --output $outPath --configuration $Configuration
127+
Remove-Item -Path "$outPath/Microsoft.PowerShell.TextUtility.deps.json" -ErrorAction SilentlyContinue
128+
if ($Configuration -eq "Release") {
129+
Remove-Item -Path "$outPath/Microsoft.PowerShell.TextUtility.pdb" -ErrorAction SilentlyContinue
130+
}
133131
}
134132

135133
if ($Test) {

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.100",
4+
"rollForward": "latestMajor"
5+
}
6+
}

nuget.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<!-- Please verify that the feed below exists for your project and replace placeholder values. You may also use another feed of your choice. -->
6+
<add key="PowerShellCore_PublicPackages" value="https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v3/index.json" />
7+
</packageSources>
8+
</configuration>

0 commit comments

Comments
 (0)