mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-23 17:53:58 +08:00
148 lines
5.7 KiB
YAML
148 lines
5.7 KiB
YAML
parameters:
|
|
- name: skipPublish
|
|
default: false
|
|
type: boolean
|
|
|
|
jobs:
|
|
- job: BuildInfoPublish
|
|
displayName: Publish BuildInfo
|
|
condition: succeeded()
|
|
pool:
|
|
type: windows
|
|
variables:
|
|
- name: runCodesignValidationInjection
|
|
value: false
|
|
- name: NugetSecurityAnalysisWarningLevel
|
|
value: none
|
|
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
|
|
value: 1
|
|
- name: ob_outputDirectory
|
|
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
|
|
- group: 'Azure Blob variable group'
|
|
- name: ob_sdl_codeSignValidation_enabled
|
|
value: false
|
|
- name: ob_sdl_binskim_enabled
|
|
value: false
|
|
- name: ob_sdl_tsa_configFile
|
|
value: $(Build.SourcesDirectory)\PowerShell\.config\tsaoptions.json
|
|
- name: ob_sdl_credscan_suppressionsFile
|
|
value: $(Build.SourcesDirectory)\PowerShell\.config\suppress.json
|
|
|
|
steps:
|
|
- checkout: self
|
|
clean: true
|
|
env:
|
|
ob_restore_phase: true # This ensures checkout is done at the beginning of the restore phase
|
|
|
|
- template: release-SetReleaseTagAndContainerName.yml
|
|
|
|
- pwsh: |
|
|
Get-ChildItem Env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
|
|
displayName: 'Capture Environment Variables'
|
|
|
|
- download: PSPackagesOfficial
|
|
artifact: BuildInfoJson
|
|
displayName: Download build info artifact
|
|
|
|
- pwsh: |
|
|
Import-Module '$(Build.SourcesDirectory)/PowerShell/tools/ci.psm1'
|
|
$jsonFile = Get-Item "$ENV:PIPELINE_WORKSPACE/PSPackagesOfficial/BuildInfoJson/*.json"
|
|
$fileName = Split-Path $jsonFile -Leaf
|
|
|
|
$dateTime = [datetime]::UtcNow
|
|
$dateTime = [datetime]::new($dateTime.Ticks - ($dateTime.Ticks % [timespan]::TicksPerSecond), $dateTime.Kind)
|
|
|
|
$metadata = Get-Content -LiteralPath '$(Build.SourcesDirectory)/PowerShell/tools/metadata.json' -ErrorAction Stop | ConvertFrom-Json
|
|
$stableRelease = $metadata.StableRelease.Latest
|
|
$ltsRelease = $metadata.LTSRelease.Latest
|
|
|
|
Write-Verbose -Verbose "Writing $jsonFile contents:"
|
|
$buildInfoJsonContent = Get-Content $jsonFile -Encoding UTF8NoBom -Raw
|
|
Write-Verbose -Verbose $buildInfoJsonContent
|
|
|
|
$buildInfo = $buildInfoJsonContent | ConvertFrom-Json
|
|
$buildInfo.ReleaseDate = $dateTime
|
|
|
|
$targetFile = "$ENV:PIPELINE_WORKSPACE/$fileName"
|
|
ConvertTo-Json -InputObject $buildInfo | Out-File $targetFile -Encoding ascii
|
|
|
|
if ($stableRelease -or $fileName -eq "preview.json") {
|
|
Set-BuildVariable -Name CopyMainBuildInfo -Value YES
|
|
} else {
|
|
Set-BuildVariable -Name CopyMainBuildInfo -Value NO
|
|
}
|
|
|
|
Set-BuildVariable -Name BuildInfoJsonFile -Value $targetFile
|
|
|
|
## Create 'lts.json' if it's the latest stable and also a LTS release.
|
|
|
|
if ($fileName -eq "stable.json") {
|
|
if ($ltsRelease) {
|
|
$ltsFile = "$ENV:PIPELINE_WORKSPACE/lts.json"
|
|
Copy-Item -Path $targetFile -Destination $ltsFile -Force
|
|
Set-BuildVariable -Name LtsBuildInfoJsonFile -Value $ltsFile
|
|
Set-BuildVariable -Name CopyLTSBuildInfo -Value YES
|
|
} else {
|
|
Set-BuildVariable -Name CopyLTSBuildInfo -Value NO
|
|
}
|
|
|
|
$releaseTag = $buildInfo.ReleaseTag
|
|
$version = $releaseTag -replace '^v'
|
|
$semVersion = [System.Management.Automation.SemanticVersion] $version
|
|
|
|
$versionFile = "$ENV:PIPELINE_WORKSPACE/$($semVersion.Major)-$($semVersion.Minor).json"
|
|
Copy-Item -Path $targetFile -Destination $versionFile -Force
|
|
Set-BuildVariable -Name VersionBuildInfoJsonFile -Value $versionFile
|
|
Set-BuildVariable -Name CopyVersionBuildInfo -Value YES
|
|
} else {
|
|
Set-BuildVariable -Name CopyVersionBuildInfo -Value NO
|
|
}
|
|
displayName: Create json files
|
|
|
|
- pwsh: |
|
|
$azureRmModule = Get-InstalledModule AzureRM -ErrorAction SilentlyContinue -Verbose
|
|
if ($azureRmModule) {
|
|
Write-Host 'AzureRM module exists. Removing it'
|
|
Uninstall-AzureRm
|
|
Write-Host 'AzureRM module removed'
|
|
}
|
|
|
|
Install-Module -Name Az.Storage -Force -AllowClobber -Scope CurrentUser -Verbose
|
|
displayName: Remove AzRM modules
|
|
|
|
- task: AzurePowerShell@5
|
|
displayName: Upload buildjson to blob
|
|
inputs:
|
|
azureSubscription: az-blob-cicd-infra
|
|
scriptType: inlineScript
|
|
azurePowerShellVersion: LatestVersion
|
|
pwsh: true
|
|
inline: |
|
|
$containerName = '$web'
|
|
$storageAccount = '$(PSInfraStorageAccount)'
|
|
$prefix = "buildinfo"
|
|
|
|
$storageContext = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount
|
|
|
|
if ($env:CopyMainBuildInfo -eq 'YES') {
|
|
$jsonFile = "$env:BuildInfoJsonFile"
|
|
$blobName = Get-Item $jsonFile | Split-Path -Leaf
|
|
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
|
|
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
|
|
}
|
|
|
|
if ($env:CopyLTSBuildInfo -eq 'YES') {
|
|
$jsonFile = "$env:LtsBuildInfoJsonFile"
|
|
$blobName = Get-Item $jsonFile | Split-Path -Leaf
|
|
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
|
|
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
|
|
}
|
|
|
|
if ($env:CopyVersionBuildInfo -eq 'YES') {
|
|
$jsonFile = "$env:VersionBuildInfoJsonFile"
|
|
$blobName = Get-Item $jsonFile | Split-Path -Leaf
|
|
Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName"
|
|
Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force
|
|
}
|
|
condition: and(succeeded(), eq(variables['CopyMainBuildInfo'], 'YES'))
|