Publish PowerShell vPack for stable and better builds (#11960)

This commit is contained in:
Travis Plunk
2020-02-27 10:13:29 -08:00
committed by GitHub
parent 277b277b57
commit c97f2d7fd7
2 changed files with 141 additions and 0 deletions
@@ -0,0 +1,86 @@
parameters:
architecture: x64
jobs:
- job: vpack_${{ parameters.architecture }}
displayName: Build and Publish VPack - ${{ parameters.architecture }}
condition: succeeded()
pool: Package ES Standard Build
steps:
- template: ./SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- pwsh: |
$azcopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Write-Host "running: $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:****** /Pattern:PowerShell-$(Version)-win-${{ parameters.architecture }}.zip /Z:$(AGENT.TEMPDIRECTORY)"
& $azcopy /Source:https://$(StorageAccount).blob.core.windows.net/$(AzureVersion) /Dest:$(System.ArtifactsDirectory) /S /SourceKey:$(StorageAccountKey) /Pattern:PowerShell-$(Version)-win-${{ parameters.architecture }}.zip /Z:$(AGENT.TEMPDIRECTORY)
displayName: 'Download Azure Artifacts'
- pwsh: 'Get-ChildItem $(System.ArtifactsDirectory)\* -recurse | Select-Object -ExpandProperty Name'
displayName: 'Capture Artifact Listing'
- pwsh: |
$message = @()
Get-ChildItem $(System.ArtifactsDirectory)\* -recurse -include *.zip, *.msi | ForEach-Object {
if($_.Name -notmatch 'PowerShell-\d\.\d\.\d\-([a-z]*.\d+\-)?win\-(fxdependent|x64|arm32|arm64|x86|fxdependentWinDesktop)\.(msi|zip){1}')
{
$messageInstance = "$($_.Name) is not a valid package name"
$message += $messageInstance
Write-Warning $messageInstance
}
}
if($message.count -gt 0){throw ($message | out-string)}
displayName: 'Validate Zip and MSI Package Names'
- pwsh: |
Get-ChildItem $(System.ArtifactsDirectory)\* -recurse -include *.zip, *.msi | ForEach-Object {
if($_.Name -match 'PowerShell-\d\.\d\.\d\-([a-z]*.\d+\-)?win\-(${{ parameters.architecture }})\.(zip){1}')
{
$destDir = "$(System.ArtifactsDirectory)\vpack${{ parameters.architecture }}"
$null = new-item -ItemType Directory -Path $destDir
Expand-Archive -Path $_.FullName -DestinationPath $destDir
$vstsCommandString = "vso[task.setvariable variable=vpackDir]$destDir"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
}
}
displayName: 'Extract Zip'
- pwsh: |
$vpackVersion = '$(version)'
if('$(VPackPublishOverride)' -ne '' -and '$(VPackPublishOverride)' -ne 'None' )
{
Write-Host "Using VPackPublishOverride varabile"
$vpackVersion = '$(VPackPublishOverride)'
}
$vstsCommandString = "vso[task.setvariable variable=vpackVersion]$vpackVersion"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Set vpackVersion'
- pwsh: |
Get-ChildItem -Path env:
displayName: Capture Environment
condition: succeededOrFailed()
- task: PkgESVPack@10
displayName: 'Package ES - VPack '
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
sourceDirectory: '$(vpackDir)'
description: PowerShell ${{ parameters.architecture }} $(version)
pushPkgName: 'PowerShell.${{ parameters.architecture }}'
configurations: Release
platforms: x64
target: '$(System.ArtifactsDirectory)'
owner: tplunk
provData: false
version: '$(vpackVersion)'
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
@@ -0,0 +1,55 @@
name: vpack-$(Build.BuildId)
trigger:
branches:
include:
- master
- release*
pr:
branches:
include:
- master
- release*
variables:
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: POWERSHELL_TELEMETRY_OPTOUT
value: 1
- group: Azure Blob variable group
# Set AzDevOps Agent to clean the machine after the end of the build
resources:
- repo: self
clean: true
jobs:
- job: rename
displayName: Name the build
condition: succeeded()
pool:
vmImage: 'windows-latest'
steps:
- template: ./templates/SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')
- template: ./templates/vpackReleaseJob.yml
parameters:
architecture: x64
- template: ./templates/vpackReleaseJob.yml
parameters:
architecture: x86
- template: ./templates/vpackReleaseJob.yml
parameters:
architecture: arm32
- template: ./templates/vpackReleaseJob.yml
parameters:
architecture: arm64