Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 3c82876

Browse files
authored
Add CI release/publish to RemotingTools, SecretManagement, ThreadJob modules (#78)
1 parent f5074c3 commit 3c82876

File tree

11 files changed

+142
-88
lines changed

11 files changed

+142
-88
lines changed

Modules/Microsoft.PowerShell.RemotingTools/.ci/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ stages:
5656
Install-Module -Name PSPackageProject -Force
5757
$config = Get-PSPackageProjectConfiguration
5858
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
59-
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
59+
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
6060
if (! (Test-Path -Path $signOutPath)) {
6161
$null = New-Item -Path $signOutPath -ItemType Directory
6262
}
63+
Write-Host "Signed output path is: $signOutPath"
6364
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
6465
Write-Host "sending " + $vstsCommandString
6566
Write-Host "##$vstsCommandString"
@@ -88,6 +89,10 @@ stages:
8889
binVersionOverride: ''
8990
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
9091

92+
- pwsh: |
93+
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
94+
displayName: Create signed artifact
95+
9196
- stage: Compliance
9297
displayName: Compliance
9398
dependsOn: Build
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
parameters:
22
jobName: release
33
imageName: windows-2019
4-
displayName: Release
4+
displayName: 'Release Microsoft.PowerShell.RemotingTools to NuGet'
55

66
jobs:
77
- job: ${{ parameters.jobName }}
88
pool:
99
vmImage: ${{ parameters.imageName }}
1010
displayName: ${{ parameters.displayName }}
11+
1112
steps:
1213
- task: DownloadBuildArtifacts@0
1314
displayName: 'Download artifacts'
1415
inputs:
1516
buildType: current
16-
downloadType: single
17-
artifactName: NuPkg
17+
downloadType: specific
18+
itemPattern: '**/*.nupkg'
1819
downloadPath: '$(System.ArtifactsDirectory)'
20+
1921
- task: NuGetToolInstaller@1
2022
displayName: 'Install NuGet'
21-
- pwsh: |
22-
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
23-
displayName: Publish Package
23+
24+
- powershell: |
25+
Get-ChildItem '$(Build.ArtifactStagingDirectory)/Microsoft.PowerShell.RemotingTools.*.nupkg'
26+
displayName: 'Capture NuGet package'
27+
28+
- task: NuGetCommand@2
29+
displayName: 'Push PSThreadJob artifacts to AzArtifactsFeed'
30+
inputs:
31+
command: push
32+
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.RemotingTools.*.nupkg'
33+
nuGetFeedType: external
34+
publishFeedCredentials: AzArtifactFeed

Modules/Microsoft.PowerShell.RemotingTools/build.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
# Do NOT edit this file. Edit dobuild.ps1
5+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
46
param (
57
[Parameter(ParameterSetName="build")]
68
[switch]
@@ -10,6 +12,14 @@ param (
1012
[switch]
1113
$Build,
1214

15+
[Parameter(ParameterSetName="publish")]
16+
[switch]
17+
$Publish,
18+
19+
[Parameter(ParameterSetName="publish")]
20+
[switch]
21+
$Signed,
22+
1323
[Parameter(ParameterSetName="build")]
1424
[switch]
1525
$Test,
@@ -29,6 +39,7 @@ $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot
2939
$script:ModuleName = $config.ModuleName
3040
$script:SrcPath = $config.SourcePath
3141
$script:OutDirectory = $config.BuildOutputPath
42+
$script:SignedDirectory = $config.SignedOutputPath
3243
$script:TestPath = $config.TestPath
3344

3445
$script:ModuleRoot = $PSScriptRoot
@@ -100,7 +111,12 @@ else
100111
if ($Build.IsPresent)
101112
{
102113
$sb = (Get-Item Function:DoBuild).ScriptBlock
103-
Invoke-PSPackageProjectBuild -BuildScript $sb
114+
Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish
115+
}
116+
117+
if ($Publish.IsPresent)
118+
{
119+
Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent
104120
}
105121

106122
if ( $Test.IsPresent ) {

Modules/Microsoft.PowerShell.SecretManagement/.ci/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ stages:
7171
Install-Module -Name PSPackageProject -Force
7272
$config = Get-PSPackageProjectConfiguration
7373
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
74-
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
74+
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
7575
if (! (Test-Path -Path $signOutPath)) {
7676
$null = New-Item -Path $signOutPath -ItemType Directory
7777
}
78+
Write-Host "Signed output path is: $signOutPath"
7879
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
7980
# Set signing src path variable
8081
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
@@ -107,6 +108,10 @@ stages:
107108
binVersionOverride: ''
108109
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
109110

111+
- pwsh: |
112+
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
113+
displayName: Create signed artifact
114+
110115
- stage: Compliance
111116
displayName: Compliance
112117
dependsOn: Build
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
parameters:
22
jobName: release
33
imageName: windows-2019
4-
displayName: Release
4+
displayName: 'Release Microsoft.PowerShell.SecretManagement to NuGet'
55

66
jobs:
77
- job: ${{ parameters.jobName }}
88
pool:
99
vmImage: ${{ parameters.imageName }}
1010
displayName: ${{ parameters.displayName }}
11+
1112
steps:
1213
- task: DownloadBuildArtifacts@0
1314
displayName: 'Download artifacts'
1415
inputs:
1516
buildType: current
16-
downloadType: single
17-
artifactName: NuPkg
17+
downloadType: specific
18+
artifactName: '**/*.nupkg'
1819
downloadPath: '$(System.ArtifactsDirectory)'
20+
1921
- task: NuGetToolInstaller@1
2022
displayName: 'Install NuGet'
21-
- pwsh: |
22-
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
23-
displayName: Publish Package
23+
24+
- powershell: |
25+
Get-ChildItem '$(System.ArtifactsDirectory)/Microsoft.PowerShell.SecretManagement.*.nupkg'
26+
displayName: 'Capture NuGet package'
27+
28+
- task: NuGetCommand@2
29+
displayName: 'Push Microsoft.PowerShell.SecretManagement artifacts to AzArtifactsFeed'
30+
inputs:
31+
command: push
32+
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.SecretManagement.*.nupkg'
33+
nuGetFeedType: external
34+
publishFeedCredentials: AzArtifactFeed

Modules/Microsoft.PowerShell.SecretManagement/build.ps1

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
# Do NOT edit this file. Edit dobuild.ps1
5+
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
46
param (
57
[Parameter(ParameterSetName="build")]
68
[switch]
@@ -10,6 +12,14 @@ param (
1012
[switch]
1113
$Build,
1214

15+
[Parameter(ParameterSetName="publish")]
16+
[switch]
17+
$Publish,
18+
19+
[Parameter(ParameterSetName="publish")]
20+
[switch]
21+
$Signed,
22+
1323
[Parameter(ParameterSetName="build")]
1424
[switch]
1525
$Test,
@@ -39,6 +49,7 @@ $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot
3949
$script:ModuleName = $config.ModuleName
4050
$script:SrcPath = $config.SourcePath
4151
$script:OutDirectory = $config.BuildOutputPath
52+
$script:SignedDirectory = $config.SignedOutputPath
4253
$script:TestPath = $config.TestPath
4354

4455
$script:ModuleRoot = $PSScriptRoot
@@ -48,39 +59,17 @@ $script:HelpPath = $config.HelpPath
4859
$script:BuildConfiguration = $BuildConfiguration
4960
$script:BuildFramework = $BuildFramework
5061

51-
. "$PSScriptRoot\doBuild.ps1"
52-
53-
# The latest DotNet (3.1.1) is needed to perform binary build.
54-
$dotNetCmd = Get-Command -Name dotNet -ErrorAction SilentlyContinue
55-
$dotnetVersion = $null
56-
if ($dotNetCmd -ne $null) {
57-
$info = dotnet --info
58-
foreach ($item in $info) {
59-
$index = $item.IndexOf('Version:')
60-
if ($index -gt -1) {
61-
$versionStr = $item.SubString('Version:'.Length + $index)
62-
$null = [version]::TryParse($versionStr, [ref] $dotnetVersion)
63-
break
64-
}
65-
}
66-
}
67-
# DotNet 3.1.1 is installed in ci.yml. Just check installation and version here.
68-
Write-Verbose -Verbose -Message "Installed DotNet found: $($dotNetCmd -ne $null), version: $versionStr"
69-
<#
70-
$dotNetVersionOk = ($dotnetVersion -ne $null) -and ((($dotnetVersion.Major -eq 3) -and ($dotnetVersion.Minor -ge 1)) -or ($dotnetVersion.Major -gt 3))
71-
if (! $dotNetVersionOk) {
72-
73-
Write-Verbose -Verbose -Message "Installing dotNet..."
74-
$installObtainUrl = "https://dotnet.microsoft.com/download/dotnet-core/scripts/v1"
75-
76-
Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet
77-
$installScript = "dotnet-install.ps1"
78-
Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript
79-
80-
& ./$installScript -Channel 'release' -Version '3.1.101'
81-
Write-Verbose -Verbose -Message "dotNet installation complete."
62+
if ($env:TF_BUILD) {
63+
$vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory"
64+
Write-Host ("sending " + $vstsCommandString)
65+
Write-Host "##$vstsCommandString"
66+
67+
$vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory"
68+
Write-Host ("sending " + $vstsCommandString)
69+
Write-Host "##$vstsCommandString"
8270
}
83-
#>
71+
72+
. $PSScriptRoot\dobuild.ps1
8473

8574
if ($Clean -and (Test-Path $OutDirectory))
8675
{
@@ -109,7 +98,12 @@ else
10998
if ($Build.IsPresent)
11099
{
111100
$sb = (Get-Item Function:DoBuild).ScriptBlock
112-
Invoke-PSPackageProjectBuild -BuildScript $sb
101+
Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish
102+
}
103+
104+
if ($Publish.IsPresent)
105+
{
106+
Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent
113107
}
114108

115109
if ( $Test.IsPresent ) {

Modules/Microsoft.PowerShell.SecretManagement/pspackageproject.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"ModuleName": "Microsoft.PowerShell.SecretManagement",
33
"Culture": "en-US",
44
"BuildOutputPath": "out",
5+
"SignedOutputPath": "signed",
56
"HelpPath": "help",
67
"TestPath": "test",
78
"SourcePath": "src"

Modules/Microsoft.PowerShell.ThreadJob/.ci/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ stages:
7171
Install-Module -Name PSPackageProject -Force
7272
$config = Get-PSPackageProjectConfiguration
7373
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
74-
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
74+
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
7575
if (! (Test-Path -Path $signOutPath)) {
7676
$null = New-Item -Path $signOutPath -ItemType Directory
7777
}
78+
Write-Host "Signed output path is: $signOutPath"
7879
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
7980
# Set signing src path variable
8081
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
@@ -107,6 +108,10 @@ stages:
107108
binVersionOverride: ''
108109
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
109110

111+
- pwsh: |
112+
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
113+
displayName: Create signed artifact
114+
110115
- stage: Compliance
111116
displayName: Compliance
112117
dependsOn: Build
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
parameters:
22
jobName: release
33
imageName: windows-2019
4-
displayName: Release
4+
displayName: 'Release Microsoft.PowerShell.ThreadJob to NuGet'
55

66
jobs:
77
- job: ${{ parameters.jobName }}
88
pool:
99
vmImage: ${{ parameters.imageName }}
1010
displayName: ${{ parameters.displayName }}
11+
1112
steps:
1213
- task: DownloadBuildArtifacts@0
1314
displayName: 'Download artifacts'
1415
inputs:
1516
buildType: current
16-
downloadType: single
17-
artifactName: NuPkg
17+
downloadType: specific
18+
itemPattern: '**/*.nupkg'
1819
downloadPath: '$(System.ArtifactsDirectory)'
20+
1921
- task: NuGetToolInstaller@1
2022
displayName: 'Install NuGet'
21-
- pwsh: |
22-
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
23-
displayName: Publish Package
23+
24+
- powershell: |
25+
Get-ChildItem '$(System.ArtifactsDirectory)/Microsoft.PowerShell.ThreadJob.*.nupkg'
26+
displayName: 'Capture NuGet package'
27+
28+
- task: NuGetCommand@2
29+
displayName: 'Push PSThreadJob artifacts to AzArtifactsFeed'
30+
inputs:
31+
command: push
32+
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.ThreadJob.*.nupkg'
33+
nuGetFeedType: external
34+
publishFeedCredentials: AzArtifactFeed

0 commit comments

Comments
 (0)