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

Add CI release/publish to RemotingTools, SecretManagement, ThreadJob modules #78

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Modules/Microsoft.PowerShell.RemotingTools/.ci/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ stages:
Install-Module -Name PSPackageProject -Force
$config = Get-PSPackageProjectConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
if (! (Test-Path -Path $signOutPath)) {
$null = New-Item -Path $signOutPath -ItemType Directory
}
Write-Host "Signed output path is: $signOutPath"
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
Expand Down Expand Up @@ -88,6 +89,10 @@ stages:
binVersionOverride: ''
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))

- pwsh: |
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Create signed artifact

- stage: Compliance
displayName: Compliance
dependsOn: Build
Expand Down
23 changes: 17 additions & 6 deletions Modules/Microsoft.PowerShell.RemotingTools/.ci/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
parameters:
jobName: release
imageName: windows-2019
displayName: Release
displayName: 'Release Microsoft.PowerShell.RemotingTools to NuGet'

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.imageName }}
displayName: ${{ parameters.displayName }}

steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: single
artifactName: NuPkg
downloadType: specific
itemPattern: '**/*.nupkg'
downloadPath: '$(System.ArtifactsDirectory)'

- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
- pwsh: |
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
displayName: Publish Package

- powershell: |
Get-ChildItem '$(Build.ArtifactStagingDirectory)/Microsoft.PowerShell.RemotingTools.*.nupkg'
displayName: 'Capture NuGet package'

- task: NuGetCommand@2
displayName: 'Push PSThreadJob artifacts to AzArtifactsFeed'
inputs:
command: push
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.RemotingTools.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: AzArtifactFeed
18 changes: 17 additions & 1 deletion Modules/Microsoft.PowerShell.RemotingTools/build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Do NOT edit this file. Edit dobuild.ps1
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
param (
[Parameter(ParameterSetName="build")]
[switch]
Expand All @@ -10,6 +12,14 @@ param (
[switch]
$Build,

[Parameter(ParameterSetName="publish")]
[switch]
$Publish,

[Parameter(ParameterSetName="publish")]
[switch]
$Signed,

[Parameter(ParameterSetName="build")]
[switch]
$Test,
Expand All @@ -29,6 +39,7 @@ $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot
$script:ModuleName = $config.ModuleName
$script:SrcPath = $config.SourcePath
$script:OutDirectory = $config.BuildOutputPath
$script:SignedDirectory = $config.SignedOutputPath
$script:TestPath = $config.TestPath

$script:ModuleRoot = $PSScriptRoot
Expand Down Expand Up @@ -100,7 +111,12 @@ else
if ($Build.IsPresent)
{
$sb = (Get-Item Function:DoBuild).ScriptBlock
Invoke-PSPackageProjectBuild -BuildScript $sb
Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish
}

if ($Publish.IsPresent)
{
Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent
}

if ( $Test.IsPresent ) {
Expand Down
7 changes: 6 additions & 1 deletion Modules/Microsoft.PowerShell.SecretManagement/.ci/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ stages:
Install-Module -Name PSPackageProject -Force
$config = Get-PSPackageProjectConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
if (! (Test-Path -Path $signOutPath)) {
$null = New-Item -Path $signOutPath -ItemType Directory
}
Write-Host "Signed output path is: $signOutPath"
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
# Set signing src path variable
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
Expand Down Expand Up @@ -107,6 +108,10 @@ stages:
binVersionOverride: ''
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))

- pwsh: |
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Create signed artifact

- stage: Compliance
displayName: Compliance
dependsOn: Build
Expand Down
23 changes: 17 additions & 6 deletions Modules/Microsoft.PowerShell.SecretManagement/.ci/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
parameters:
jobName: release
imageName: windows-2019
displayName: Release
displayName: 'Release Microsoft.PowerShell.SecretManagement to NuGet'

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.imageName }}
displayName: ${{ parameters.displayName }}

steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: single
artifactName: NuPkg
downloadType: specific
artifactName: '**/*.nupkg'
downloadPath: '$(System.ArtifactsDirectory)'

- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
- pwsh: |
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
displayName: Publish Package

- powershell: |
Get-ChildItem '$(System.ArtifactsDirectory)/Microsoft.PowerShell.SecretManagement.*.nupkg'
displayName: 'Capture NuGet package'

- task: NuGetCommand@2
displayName: 'Push Microsoft.PowerShell.SecretManagement artifacts to AzArtifactsFeed'
inputs:
command: push
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.SecretManagement.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: AzArtifactFeed
60 changes: 27 additions & 33 deletions Modules/Microsoft.PowerShell.SecretManagement/build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

# Do NOT edit this file. Edit dobuild.ps1
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
param (
[Parameter(ParameterSetName="build")]
[switch]
Expand All @@ -10,6 +12,14 @@ param (
[switch]
$Build,

[Parameter(ParameterSetName="publish")]
[switch]
$Publish,

[Parameter(ParameterSetName="publish")]
[switch]
$Signed,

[Parameter(ParameterSetName="build")]
[switch]
$Test,
Expand Down Expand Up @@ -39,6 +49,7 @@ $config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot
$script:ModuleName = $config.ModuleName
$script:SrcPath = $config.SourcePath
$script:OutDirectory = $config.BuildOutputPath
$script:SignedDirectory = $config.SignedOutputPath
$script:TestPath = $config.TestPath

$script:ModuleRoot = $PSScriptRoot
Expand All @@ -48,39 +59,17 @@ $script:HelpPath = $config.HelpPath
$script:BuildConfiguration = $BuildConfiguration
$script:BuildFramework = $BuildFramework

. "$PSScriptRoot\doBuild.ps1"

# The latest DotNet (3.1.1) is needed to perform binary build.
$dotNetCmd = Get-Command -Name dotNet -ErrorAction SilentlyContinue
$dotnetVersion = $null
if ($dotNetCmd -ne $null) {
$info = dotnet --info
foreach ($item in $info) {
$index = $item.IndexOf('Version:')
if ($index -gt -1) {
$versionStr = $item.SubString('Version:'.Length + $index)
$null = [version]::TryParse($versionStr, [ref] $dotnetVersion)
break
}
}
}
# DotNet 3.1.1 is installed in ci.yml. Just check installation and version here.
Write-Verbose -Verbose -Message "Installed DotNet found: $($dotNetCmd -ne $null), version: $versionStr"
<#
$dotNetVersionOk = ($dotnetVersion -ne $null) -and ((($dotnetVersion.Major -eq 3) -and ($dotnetVersion.Minor -ge 1)) -or ($dotnetVersion.Major -gt 3))
if (! $dotNetVersionOk) {

Write-Verbose -Verbose -Message "Installing dotNet..."
$installObtainUrl = "https://dotnet.microsoft.com/download/dotnet-core/scripts/v1"

Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet
$installScript = "dotnet-install.ps1"
Invoke-WebRequest -Uri $installObtainUrl/$installScript -OutFile $installScript

& ./$installScript -Channel 'release' -Version '3.1.101'
Write-Verbose -Verbose -Message "dotNet installation complete."
if ($env:TF_BUILD) {
$vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"

$vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
}
#>

. $PSScriptRoot\dobuild.ps1

if ($Clean -and (Test-Path $OutDirectory))
{
Expand Down Expand Up @@ -109,7 +98,12 @@ else
if ($Build.IsPresent)
{
$sb = (Get-Item Function:DoBuild).ScriptBlock
Invoke-PSPackageProjectBuild -BuildScript $sb
Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish
}

if ($Publish.IsPresent)
{
Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent
}

if ( $Test.IsPresent ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ModuleName": "Microsoft.PowerShell.SecretManagement",
"Culture": "en-US",
"BuildOutputPath": "out",
"SignedOutputPath": "signed",
"HelpPath": "help",
"TestPath": "test",
"SourcePath": "src"
Expand Down
7 changes: 6 additions & 1 deletion Modules/Microsoft.PowerShell.ThreadJob/.ci/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ stages:
Install-Module -Name PSPackageProject -Force
$config = Get-PSPackageProjectConfiguration
$signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
$signOutPath = "$($config.BuildOutputPath)\$($config.ModuleName)\Signed"
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
if (! (Test-Path -Path $signOutPath)) {
$null = New-Item -Path $signOutPath -ItemType Directory
}
Write-Host "Signed output path is: $signOutPath"
$signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml"
# Set signing src path variable
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}"
Expand Down Expand Up @@ -107,6 +108,10 @@ stages:
binVersionOverride: ''
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))

- pwsh: |
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
displayName: Create signed artifact

- stage: Compliance
displayName: Compliance
dependsOn: Build
Expand Down
23 changes: 17 additions & 6 deletions Modules/Microsoft.PowerShell.ThreadJob/.ci/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
parameters:
jobName: release
imageName: windows-2019
displayName: Release
displayName: 'Release Microsoft.PowerShell.ThreadJob to NuGet'

jobs:
- job: ${{ parameters.jobName }}
pool:
vmImage: ${{ parameters.imageName }}
displayName: ${{ parameters.displayName }}

steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
buildType: current
downloadType: single
artifactName: NuPkg
downloadType: specific
itemPattern: '**/*.nupkg'
downloadPath: '$(System.ArtifactsDirectory)'

- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
- pwsh: |
nuget push $(System.ArtifactsDirectory)\nupkg\*.nupkg -ApiKey $(NuGetApiKey) -Source https://www.powershellgallery.com/api/v2/package/ -NonInteractive
displayName: Publish Package

- powershell: |
Get-ChildItem '$(System.ArtifactsDirectory)/Microsoft.PowerShell.ThreadJob.*.nupkg'
displayName: 'Capture NuGet package'

- task: NuGetCommand@2
displayName: 'Push PSThreadJob artifacts to AzArtifactsFeed'
inputs:
command: push
packagesToPush: '$(System.ArtifactsDirectory)/Microsoft.PowerShell.ThreadJob.*.nupkg'
nuGetFeedType: external
publishFeedCredentials: AzArtifactFeed
Loading