Skip to content

Commit f40a2a5

Browse files
Azure pipelines (#104)
1 parent dd6951f commit f40a2a5

16 files changed

+633
-93
lines changed

.config/tsaoptions.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"hasDynamicRouting": true,
3+
"areaPath": "OS",
4+
"notificationAliases": [
5+
6+
7+
8+
9+
],
10+
"codebaseName": "TFSMSAzure_powershell-native"
11+
}

.pipelines/release.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
trigger: none
2+
3+
parameters:
4+
- name: OfficialBuild
5+
type: boolean
6+
default: false
7+
- name: disableNetworkIsolation
8+
type: boolean
9+
default: false
10+
11+
variables:
12+
- name: ob_outputDirectory
13+
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
14+
- name: LinuxContainerImage
15+
value: mcr.microsoft.com/onebranch/azurelinux/build:3.0
16+
- name: WindowsContainerImage
17+
value: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest
18+
- name: templateFile
19+
value: ${{ iif ( parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@templates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@templates' ) }}
20+
- name: disableNetworkIsolation
21+
value: ${{ parameters.disableNetworkIsolation }}
22+
23+
resources:
24+
repositories:
25+
- repository: templates
26+
type: git
27+
name: OneBranch.Pipelines/GovernedTemplates
28+
ref: refs/heads/main
29+
30+
extends:
31+
template: ${{ variables.templateFile }} # The Official template may only be used by Production-classified pipelines
32+
33+
parameters:
34+
release:
35+
category: NonAzure
36+
featureFlags:
37+
WindowsHostVersion:
38+
Disk: Large
39+
Version: 2022
40+
Network: KS1
41+
incrementalSDLBinaryAnalysis: true
42+
needExceptionForUbuntuUsage: true
43+
disableNetworkIsolation: ${{ variables.disableNetworkIsolation }}
44+
cloudvault:
45+
enabled: false
46+
globalSdl:
47+
isNativeCode: true
48+
prefast:
49+
enabled: true
50+
tsa:
51+
useDynamicRouting: true
52+
enabled: true
53+
sbom:
54+
enabled: true
55+
packageName: Microsoft.PowerShell.Native
56+
codeql:
57+
tsaEnabled: true
58+
compiled:
59+
enabled: true
60+
armory:
61+
enabled: false
62+
credscan:
63+
enabled: true
64+
scanFolder: $(Build.SourcesDirectory)
65+
binskim:
66+
enabled: true
67+
exactToolVersion: 4.4.2
68+
apiscan:
69+
enabled: false
70+
tsaOptionsFile: .config\tsaoptions.json
71+
72+
stages:
73+
- stage: WinBuildAndSign
74+
displayName: Windows Build and Sign
75+
jobs:
76+
- template: .pipelines/templates/build-sign-windows.yml@self
77+
parameters:
78+
ARCHITECTURE: 'x64'
79+
80+
- template: .pipelines/templates/build-sign-windows.yml@self
81+
parameters:
82+
ARCHITECTURE: 'x86'
83+
84+
- template: .pipelines/templates/build-sign-windows.yml@self
85+
parameters:
86+
ARCHITECTURE: 'x64_arm64'
87+
88+
- stage: LinuxBuild
89+
displayName: Linux Build
90+
jobs:
91+
- template: .pipelines/templates/build-linux.yml@self
92+
parameters:
93+
ARCHITECTURE: 'linux-x64'
94+
Name: 'Build_Linux_x64'
95+
96+
- template: .pipelines/templates/build-linux.yml@self
97+
parameters:
98+
ARCHITECTURE: 'linux-arm64'
99+
Name: 'Build_Linux_arm64'
100+
hostArchitecture: 'arm64'
101+
102+
- template: .pipelines/templates/build-linux.yml@self
103+
parameters:
104+
ARCHITECTURE: 'linux-musl-x64'
105+
Name: 'Build_Linux_musl_x64'
106+
107+
- template: .pipelines/templates/build-linux.yml@self
108+
parameters:
109+
ARCHITECTURE: 'osx'
110+
Name: 'Build_osx'
111+
112+
- stage: LinuxBuildARM
113+
displayName: Linux ARM Build
114+
variables:
115+
- name: LinuxContainerImage
116+
value: onebranch.azurecr.io/linux/ubuntu-2204:latest
117+
118+
jobs:
119+
- template: .pipelines/templates/build-linux.yml@self
120+
parameters:
121+
ARCHITECTURE: 'linux-arm'
122+
Name: 'Build_Linux_arm'
123+
124+
- stage: Build_Nuget
125+
dependsOn: [WinBuildAndSign, LinuxBuild, LinuxBuildARM]
126+
displayName: Build NuGet
127+
jobs:
128+
- template: .pipelines/templates/build-nuget.yml@self
129+
130+
- stage: Release_NuGet
131+
displayName: Release NuGet
132+
dependsOn: [Build_Nuget]
133+
variables:
134+
- name: Version
135+
value: $[ stageDependencies.Build_Nuget.Build_Nuget_Job.outputs['SetVersion.NugetPackageVersion'] ]
136+
- name: ob_release_environment
137+
value: ${{ iif ( parameters.OfficialBuild, 'Production', 'Test' ) }}
138+
jobs:
139+
- job: NuGetPublish
140+
displayName: Publish to NuGet
141+
condition: succeeded()
142+
pool:
143+
type: release
144+
os: windows
145+
templateContext:
146+
inputs:
147+
- input: pipelineArtifact
148+
artifactName: drop_Build_Nuget_Build_Nuget_Job
149+
steps:
150+
- task: PowerShell@2
151+
inputs:
152+
targetType: inline
153+
script: |
154+
Write-Verbose -Verbose "Version: $(Version)"
155+
Get-ChildItem Env:\
156+
displayName: 'Capture Environment Variables'
157+
158+
- task: PowerShell@2
159+
inputs:
160+
targetType: inline
161+
script: |
162+
$DestPath = New-Item -ItemType Directory -Path "$(Pipeline.Workspace)\release"
163+
$nupkgFile = Get-ChildItem "$(Pipeline.Workspace)\Microsoft.PowerShell.Native.*.nupkg" -Recurse
164+
if (-not $nupkgFile) {
165+
throw "No nupkg files found in '$(Pipeline.Workspace)'"
166+
}
167+
168+
Copy-Item $nupkgFile -Destination $DestPath -Recurse -Force -Verbose
169+
Write-Verbose -Verbose "The .nupkgs below will be pushed:"
170+
Get-ChildItem "$(Pipeline.Workspace)/release" -recurse
171+
displayName: Download and capture nupkgs
172+
173+
- task: NuGetCommand@2
174+
displayName: 'NuGet push'
175+
condition: and(eq('${{ parameters.OfficialBuild }}', 'true'), succeeded())
176+
inputs:
177+
command: push
178+
packagesToPush: '$(Pipeline.Workspace)\release\*.nupkg'
179+
nuGetFeedType: external
180+
publishFeedCredentials: PowerShellNuGetOrgPush
181+

.pipelines/templates/build-linux.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
parameters:
2+
- name: ARCHITECTURE
3+
type: string
4+
default: 'x64'
5+
- name: Name
6+
type: string
7+
default: 'Build_Linux_x64'
8+
- name: hostArchitecture
9+
type: string
10+
default: 'amd64'
11+
12+
jobs:
13+
- job: ${{ parameters.Name }}
14+
pool:
15+
type: linux
16+
${{ if eq(parameters.ARCHITECTURE, 'osx') }}:
17+
isCustom: true
18+
name: Azure Pipelines
19+
vmImage: 'macOS-latest'
20+
${{ if eq(parameters.hostArchitecture, 'arm64') }}:
21+
hostArchitecture: 'arm64'
22+
displayName: Linux_${{ parameters.ARCHITECTURE }}
23+
variables:
24+
- name: ob_outputDirectory
25+
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
26+
- name: ob_signing_setup_enabled
27+
value: true
28+
- name: ARCHITECTURE
29+
value: ${{ parameters.ARCHITECTURE }}
30+
- name: DOTNET_SYSTEM_GLOBALIZATION_INVARIANT
31+
value: 1
32+
- ${{ if eq(parameters.ARCHITECTURE, 'linux-arm64') }}:
33+
- name: ob_sdl_binskim_enabled
34+
value: false
35+
- name: ob_sdl_credscan_enabled
36+
value: false
37+
steps:
38+
- pwsh: |
39+
Get-ChildItem Env:\ | Out-String -Stream | Write-Verbose -Verbose
40+
displayName: Capture environment variables
41+
42+
- pwsh: |
43+
$Arch = "$(ARCHITECTURE)"
44+
$repoRoot = '$(Build.SourcesDirectory)'
45+
Import-Module $repoRoot\build.psm1 -Force
46+
47+
if ($Arch -eq 'linux-x64' -or $Arch -eq 'linux-musl-x64' -or $Arch -eq 'osx') {
48+
Start-PSBootstrap
49+
Write-Verbose "Starting Start-Start-BuildNativeUnixBinaries" -Verbose
50+
Start-BuildNativeUnixBinaries
51+
Write-Verbose "Completed Start-BuildNativeUnixBinaries" -Verbose
52+
}
53+
elseif ($Arch -eq 'linux-arm64') {
54+
Start-PSBootstrap -BuildLinuxArm64
55+
Write-Verbose "Starting Start-BuildNativeUnixBinaries" -Verbose
56+
Start-BuildNativeUnixBinaries -BuildLinuxArm64
57+
Write-Verbose "Completed Start-BuildNativeUnixBinaries" -Verbose
58+
}
59+
elseif ($Arch -eq 'linux-arm') {
60+
Start-PSBootstrap -BuildLinuxArm
61+
Write-Verbose "Starting Start-BuildNativeUnixBinaries" -Verbose
62+
Start-BuildNativeUnixBinaries -BuildLinuxArm
63+
Write-Verbose "Completed Start-BuildNativeUnixBinaries" -Verbose
64+
}
65+
else {
66+
throw "Unsupported architecture: $Arch"
67+
}
68+
69+
$buildOutputPath = Join-Path $RepoRoot "src/powershell-unix"
70+
71+
if (-not (Test-Path $(ob_outputDirectory))) {
72+
New-Item -ItemType Directory -Path $(ob_outputDirectory) -Force -Verbose
73+
}
74+
75+
Copy-Item -Path "$buildOutputPath/libpsl-native.*" -Destination "$(ob_outputDirectory)" -Force
76+
77+
if ($Arch -eq 'osx') {
78+
Write-Host "##vso[artifact.upload containerfolder=drop_osx;artifactname=drop_osx]$(ob_outputDirectory)"
79+
}
80+
displayName: 'Build'
81+
82+
83+

.pipelines/templates/build-nuget.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
jobs:
2+
- job: Build_Nuget_Job
3+
pool:
4+
type: windows
5+
displayName: Build NuGet
6+
variables:
7+
- name: ob_outputDirectory
8+
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
9+
- name: ob_signing_setup_enabled
10+
value: true
11+
steps:
12+
- pwsh: |
13+
if (-not (Test-Path -Path "$(ob_outputDirectory)")) {
14+
New-Item -ItemType Directory -Path "$(ob_outputDirectory)" | Out-Null
15+
}
16+
displayName: 'Create output directory'
17+
18+
- download: current
19+
20+
- pwsh: |
21+
Get-ChildItem -Path $(Pipeline.Workspace)
22+
displayName: 'List files in workspace'
23+
24+
- task: NuGetToolInstaller@0
25+
displayName: 'Install NuGet 5.3.1'
26+
inputs:
27+
versionSpec: 5.3.1
28+
29+
- template: setVersion.yml@self
30+
31+
- pwsh: |
32+
Get-ChildItem Env:\ | Out-String -Stream | Write-Verbose -Verbose
33+
displayName: Capture environment variables
34+
35+
- pwsh: |
36+
$platforms = @("drop_LinuxBuild_Build_Linux_arm64",
37+
"drop_LinuxBuild_Build_Linux_musl_x64",
38+
"drop_LinuxBuild_Build_Linux_x64",
39+
"drop_LinuxBuildARM_Build_Linux_arm",
40+
"drop_WinBuildAndSign_Build_Sign_x64",
41+
"drop_WinBuildAndSign_Build_Sign_x86",
42+
"drop_WinBuildAndSign_Build_Sign_x64_arm64",
43+
"drop_osx"
44+
)
45+
46+
$WindowsX64ZipPath = "$(ob_outputDirectory)/drop_WinBuildAndSign_Build_Sign_x64.zip"
47+
$WindowsX86ZipPath = "$(ob_outputDirectory)/drop_WinBuildAndSign_Build_Sign_x86.zip"
48+
$WindowsARMZipPath = "$(ob_outputDirectory)/drop_WinBuildAndSign_Build_Sign_arm.zip"
49+
$WindowsARM64ZipPath = "$(ob_outputDirectory)/drop_WinBuildAndSign_Build_Sign_x64_arm64.zip"
50+
$LinuxZipPath = "$(ob_outputDirectory)/drop_LinuxBuild_Build_Linux_x64.zip"
51+
$LinuxARMZipPath = "$(ob_outputDirectory)/drop_LinuxBuildARM_Build_Linux_arm.zip"
52+
$LinuxARM64ZipPath = "$(ob_outputDirectory)/drop_LinuxBuild_Build_Linux_arm64.zip"
53+
$LinuxAlpineZipPath = "$(ob_outputDirectory)/drop_LinuxBuild_Build_Linux_musl_x64.zip"
54+
$macOSZipPath = "$(ob_outputDirectory)/drop_osx.zip"
55+
56+
$symbolsRoot = "$(ob_outputDirectory)/symbols"
57+
New-Item -ItemType Directory -Path $symbolsRoot -Force | Out-Null
58+
59+
$platforms | ForEach-Object {
60+
$platform = $_
61+
$compressedFile = "$(ob_outputDirectory)/$platform.zip"
62+
Compress-Archive -Path "$(Pipeline.Workspace)/$platform/*" -DestinationPath $compressedFile -Force
63+
$DestPath = Join-Path $symbolsRoot $platform
64+
New-Item -Path $DestPath -ItemType Directory -Force | Out-Null
65+
Get-ChildItem -Path "$(Pipeline.Workspace)/$platform/*.pdb" -Recurse | ForEach-Object {
66+
Copy-Item -Path $_.FullName -Destination $DestPath -Force -Verbose
67+
}
68+
}
69+
70+
Import-Module $(Build.SourcesDirectory)/build.psm1 -Force
71+
$PackageRoot = New-Item -ItemType Directory -Path $(ob_outputDirectory)\NugetPackageSrc
72+
Start-BuildPowerShellNativePackage -PackageRoot $PackageRoot -Version $(PackageVersion) -WindowsX64ZipPath $WindowsX64ZipPath -WindowsX86ZipPath $WindowsX86ZipPath -WindowsARM64ZipPath $WindowsARM64ZipPath -LinuxZipPath $LinuxZipPath -LinuxARMZipPath $LinuxARMZipPath -LinuxARM64ZipPath $LinuxARM64ZipPath -LinuxAlpineZipPath $LinuxAlpineZipPath -macOSZipPath $macOSZipPath
73+
74+
Write-Verbose -Verbose "Enumerating $symbolsRoot"
75+
Get-ChildItem -Path $symbolsRoot -Recurse
76+
77+
$vstsCommandString = "vso[task.setvariable variable=SymbolsPath]$symbolsRoot"
78+
Write-Verbose -Message "$vstsCommandString" -Verbose
79+
Write-Host -Object "##$vstsCommandString"
80+
81+
Write-Verbose -Verbose "Build nupkg"
82+
New-NugetPackage -PackageRoot $PackageRoot -NuGetOutputPath '$(ob_outputDirectory)\NugetPackage'
83+
84+
Write-Verbose -Verbose "Cleanup output folder"
85+
Get-ChildItem -Path "$(ob_outputDirectory)" -Exclude "NugetPackage", "symbols" | Remove-Item -Recurse -Force -Verbose
86+
87+
Write-Verbose -Verbose "Enumerating $(ob_outputDirectory)"
88+
Get-ChildItem -Path "$(ob_outputDirectory)" -Recurse
89+
displayName: 'Build NuPkg'
90+
91+
- pwsh: |
92+
Get-ChildItem -Path "$(ob_outputDirectory)\NugetPackage" -Recurse | ForEach-Object {
93+
$file = $_
94+
Write-Verbose -Message "Found NuGet package: $($file.FullName)" -Verbose
95+
}
96+
97+
Get-ChildItem -Path "$(SymbolsPath)" -Recurse | ForEach-Object {
98+
$file = $_
99+
Write-Verbose -Message "Found symbol file: $($file.FullName)" -Verbose
100+
}
101+
displayName: 'Capture Packages'
102+
103+
- task: PublishSymbols@2
104+
inputs:
105+
symbolsFolder: '$(SymbolsPath)'
106+
searchPattern: '**/*.pdb'
107+
indexSources: false
108+
publishSymbols: true
109+
symbolServerType: teamServices
110+
detailedLog: true
111+
112+
- task: onebranch.pipeline.signing@1
113+
displayName: Sign files
114+
inputs:
115+
command: 'sign'
116+
cp_code: 'CP-401405'
117+
files_to_sign: |
118+
**\*.nupkg;
119+
search_root: $(ob_outputDirectory)

0 commit comments

Comments
 (0)