Skip to content

Commit 5c1def9

Browse files
author
Andrew
authored
Build pipeline for AzDevOps (#114)
1 parent 194a0a7 commit 5c1def9

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

SimpleBuild.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
if ((Test-Path "$PSScriptRoot\out")) {
2+
Remove-Item -Path $PSScriptRoot\out -Recurse -Force
3+
}
4+
5+
New-Item -ItemType directory -Path $PSScriptRoot\out | Out-Null
6+
New-Item -ItemType directory -Path $PSScriptRoot\out\Microsoft.PowerShell.Archive | Out-Null
7+
8+
$OutPath = Join-Path $PSScriptRoot "out"
9+
$OutModulePath = Join-Path $OutPath "Microsoft.PowerShell.Archive"
10+
11+
Copy-Item -Recurse -Path "$PSScriptRoot\Microsoft.PowerShell.Archive" -Destination $OutPath -Force
12+
13+
"Build module location: $OutModulePath" | Write-Verbose -Verbose
14+
15+
"Setting VSTS variable 'BuildOutDir' to '$OutModulePath'" | Write-Verbose -Verbose
16+
Write-Host "##vso[task.setvariable variable=BuildOutDir]$OutModulePath"
17+
18+
$psd1ModuleVersion = (Get-Content -Path "$OutModulePath\Microsoft.PowerShell.Archive.psd1" | Select-String 'ModuleVersion="(.*)"').Matches[0].Groups[1].Value
19+
"Setting VSTS variable 'PackageVersion' to '$psd1ModuleVersion'" | Write-Verbose -Verbose
20+
Write-Host "##vso[task.setvariable variable=PackageVersion]$psd1ModuleVersion"

azure-pipelines-release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr)
2+
3+
trigger: none
4+
5+
resources:
6+
repositories:
7+
- repository: ComplianceRepo
8+
type: github
9+
endpoint: ComplianceGHRepo
10+
name: PowerShell/compliance
11+
12+
variables:
13+
- name: PackageName
14+
value: 'Microsoft.PowerShell.Archive'
15+
- name: PackageVersion
16+
value: ''
17+
- name: BuildOutDir
18+
value: ''
19+
20+
stages:
21+
- stage: Build
22+
displayName: Build module
23+
pool:
24+
name: 1ES
25+
demands:
26+
- ImageOverride -equals PSMMS2019-Secure
27+
jobs:
28+
- job: BuildPkg
29+
displayName: Build module
30+
variables:
31+
- group: ESRP
32+
steps:
33+
34+
- pwsh: |
35+
& $(Build.SourcesDirectory)\SimpleBuild.ps1
36+
displayName: Build Microsoft.PowerShell.Archive module
37+
condition: succeededOrFailed()
38+
39+
- pwsh: |
40+
dir "$(BuildOutDir)\*" -Recurse
41+
displayName: Show BuildOutDirectory
42+
43+
- template: Sbom.yml@ComplianceRepo
44+
parameters:
45+
BuildDropPath: "$(BuildOutDir)"
46+
Build_Repository_Uri: 'https://github.com/PowerShell/Microsoft.PowerShell.Archive'
47+
PackageName: $(PackageName)
48+
PackageVersion: $(PackageVersion)
49+
50+
- pwsh: |
51+
dir "$(BuildOutDir)\*" -Recurse
52+
displayName: Show BuildOutDirectory
53+
54+
- pwsh: |
55+
$signSrcPath = "$(BuildOutDir)"
56+
# Set signing src path variable
57+
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
58+
Write-Host "sending " + $vstsCommandString
59+
Write-Host "##$vstsCommandString"
60+
$signOutPath = "$(Build.SourcesDirectory)\signed\Microsoft.PowerShell.Archive"
61+
$null = New-Item -ItemType Directory -Path $signOutPath
62+
# Set signing out path variable
63+
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
64+
Write-Host "sending " + $vstsCommandString
65+
Write-Host "##$vstsCommandString"
66+
# Set path variable for guardian codesign validation
67+
$vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}"
68+
Write-Host "sending " + $vstsCommandString
69+
Write-Host "##$vstsCommandString"
70+
displayName: Setup variables for signing
71+
72+
- template: EsrpSign.yml@ComplianceRepo
73+
parameters:
74+
# the folder which contains the binaries to sign
75+
buildOutputPath: $(signSrcPath)
76+
# the location to put the signed output
77+
signOutputPath: $(signOutPath)
78+
# the certificate ID to use
79+
certificateId: "CP-230012"
80+
# the file pattern to use, comma separated
81+
pattern: '*.psd1,*.psm1'
82+
83+
- pwsh: |
84+
Compress-Archive -Path "$(signOutPath)\*" -DestinationPath "$(System.ArtifactsDirectory)\Microsoft.PowerShell.Archive.zip"
85+
displayName: Create Microsoft.PowerShell.Archive.zip
86+
87+
- publish: $(System.ArtifactsDirectory)\Microsoft.PowerShell.Archive.zip
88+
artifact: SignedModule
89+
90+
- template: script-module-compliance.yml@ComplianceRepo
91+
parameters:
92+
# component-governance
93+
sourceScanPath: '$(signOutPath)'
94+
# credscan
95+
suppressionsFile: ''
96+
# TermCheck
97+
optionsRulesDBPath: ''
98+
optionsFTPath: ''
99+
# tsa-upload
100+
codeBaseName: 'Microsoft_PowerShell_Archive_2_15_2022'
101+
# selections
102+
APIScan: false # set to false when not using Windows APIs.

0 commit comments

Comments
 (0)