Change packaging to produce LTS packages (#11772)

This commit is contained in:
Aditya Patwardhan 2020-02-04 16:21:59 -08:00 committed by GitHub
parent f3cc834f0c
commit bb021a977f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 167 additions and 59 deletions

View file

@ -38,7 +38,9 @@ function Start-PSPackage {
[Switch] $SkipReleaseChecks,
[switch] $NoSudo
[switch] $NoSudo,
[switch] $LTS
)
DynamicParam {
@ -304,6 +306,7 @@ function Start-PSPackage {
PackageNameSuffix = 'fxdependent'
Version = $Version
Force = $Force
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
@ -366,6 +369,7 @@ function Start-PSPackage {
Name = $Name
Version = $Version
Force = $Force
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
@ -380,6 +384,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "arm32"
ExcludeSymbolicLinks = $true
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
@ -394,6 +399,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "arm64"
ExcludeSymbolicLinks = $true
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
@ -408,6 +414,7 @@ function Start-PSPackage {
Force = $Force
Architecture = "alpine-x64"
ExcludeSymbolicLinks = $true
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
@ -422,6 +429,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}
foreach ($Distro in $Script:DebianDistributions) {
$Arguments["Distribution"] = $Distro
@ -438,6 +446,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}
foreach ($Distro in $Script:RedhatDistributions) {
$Arguments["Distribution"] = $Distro
@ -454,6 +463,7 @@ function Start-PSPackage {
Version = $Version
Force = $Force
NoSudo = $NoSudo
LTS = $LTS
}
if ($PSCmdlet.ShouldProcess("Create $_ Package")) {
@ -492,13 +502,20 @@ function New-TarballPackage {
[switch] $Force,
[switch] $ExcludeSymbolicLinks
[switch] $ExcludeSymbolicLinks,
[switch] $LTS
)
if ($PackageNameSuffix) {
$packageName = "$Name-$Version-{0}-$Architecture-$PackageNameSuffix.tar.gz"
} else {
$packageName = "$Name-$Version-{0}-$Architecture.tar.gz"
$packageName = if ($LTS) {
"$Name-lts-$Version-{0}-$Architecture.tar.gz"
}
else {
"$Name-$Version-{0}-$Architecture.tar.gz"
}
}
if ($Environment.IsWindows) {
@ -520,8 +537,11 @@ function New-TarballPackage {
}
}
$Staging = "$PSScriptRoot/staging"
New-StagingFolder -StagingPath $Staging
if (-not $ExcludeSymbolicLinks.IsPresent) {
New-PSSymbolicLinks -Distribution 'ubuntu.16.04' -Staging $PackageSourcePath
New-PSSymbolicLinks -Distribution 'ubuntu.16.04' -Staging $Staging
}
if (Get-Command -Name tar -CommandType Application -ErrorAction Ignore) {
@ -533,7 +553,7 @@ function New-TarballPackage {
}
try {
Push-Location -Path $PackageSourcePath
Push-Location -Path $Staging
tar $options $packagePath .
} finally {
Pop-Location
@ -681,7 +701,10 @@ function New-UnixPackage {
$Force,
[switch]
$NoSudo
$NoSudo,
[switch]
$LTS
)
DynamicParam {
@ -767,7 +790,15 @@ function New-UnixPackage {
$IsPreview = Test-IsPreview -Version $Version
# Preview versions have preview in the name
$Name = if ($IsPreview) { "powershell-preview" } else { "powershell" }
$Name = if($LTS) {
"powershell-lts"
}
elseif ($IsPreview) {
"powershell-preview"
}
else {
"powershell"
}
# Verify dependencies are installed and in the path
Test-Dependencies
@ -779,7 +810,7 @@ function New-UnixPackage {
$MajorVersion = $VersionMatch.Groups[1].Value
# Suffix is used for side-by-side preview/release package installation
$Suffix = if ($IsPreview) { $MajorVersion + "-preview" } else { $MajorVersion }
$Suffix = if ($IsPreview) { $MajorVersion + "-preview" } elseif ($LTS) { $MajorVersion + "-lts" } else { $MajorVersion }
# Setup staging directory so we don't change the original source directory
$Staging = "$PSScriptRoot/staging"
@ -795,11 +826,7 @@ function New-UnixPackage {
}
# Destination for symlink to powershell executable
$Link = if ($Environment.IsLinux) {
if ($IsPreview) { "/usr/bin/pwsh-preview" } else { "/usr/bin/pwsh" }
} elseif ($Environment.IsMacOS) {
if ($IsPreview) { "/usr/local/bin/pwsh-preview" } else { "/usr/local/bin/pwsh" }
}
$Link = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS
$linkSource = "/tmp/pwsh"
if ($PSCmdlet.ShouldProcess("Create package file system"))
@ -1382,14 +1409,16 @@ function New-MacOSLauncher
{
param(
[Parameter(Mandatory)]
[String]$Version
[String]$Version,
[switch]$LTS
)
$IsPreview = Test-IsPreview -Version $Version
$packageId = Get-MacOSPackageId -IsPreview:$IsPreview
# Define folder for launcher application.
$suffix = if ($IsPreview) { "-preview" }
$suffix = if ($IsPreview) { "-preview" } elseif ($LTS) { "-lts" }
$macosapp = "$PSScriptRoot/macos/launcher/ROOT/Applications/PowerShell$suffix.app"
# Create folder structure for launcher application.
@ -1416,7 +1445,7 @@ function New-MacOSLauncher
$plistcontent | Out-File -Force -Path $plist -Encoding utf8
# Create shell script.
$executablepath = if ($IsPreview) { "/usr/local/bin/pwsh-preview" } else { "/usr/local/bin/pwsh" }
$executablepath = Get-PwshExecutablePath -IsPreview:$IsPreview -IsLTS:$LTS
$shellscript = "$macosapp/Contents/MacOS/PowerShell.sh"
$shellscriptcontent = $packagingStrings.MacOSLauncherScript -f $executablepath
$shellscriptcontent | Out-File -Force -Path $shellscript -Encoding utf8
@ -1433,6 +1462,33 @@ function New-MacOSLauncher
return $appsfolder
}
function Get-PwshExecutablePath
{
param(
[switch] $IsPreview,
[switch] $IsLTS
)
if ($IsPreview -and $IsLTS)
{
throw "Cannot be LTS and Preview"
}
$executableName = if ($IsPreview) {
"pwsh-preview"
} elseif ($LTS) {
"pwsh-lts"
} else {
"pwsh"
}
if ($Environment.IsLinux) {
"/usr/bin/$executableName"
} elseif ($Environment.IsMacOS) {
"/usr/local/bin/$executableName"
}
}
function Clear-MacOSLauncher
{
# This is needed to prevent installer from picking up

View file

@ -28,55 +28,77 @@ if ($ReleaseTag)
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
}
Push-Location
try {
Set-Location $location
Import-Module "$location/build.psm1"
Import-Module "$location/tools/packaging"
#Remove the initial 'v' from the ReleaseTag
$version = $ReleaseTag -replace '^v'
$semVersion = [System.Management.Automation.SemanticVersion] $version
Start-PSBootstrap -Package -NoSudo
## All even minor versions are LTS
$LTS = if ( $semVersion.PreReleaseLabel -eq $null -and $semVersion.Minor % 2 -eq 0) {
$true
} else {
$false
}
$buildParams = @{ Configuration = 'Release'; PSModuleRestore = $true}
function BuildPackages {
param(
[switch] $LTS
)
if($FxDependent.IsPresent) {
$projectAssetsZipName = 'linuxFxDependantProjectAssetssymbols.zip'
$buildParams.Add("Runtime", "fxdependent")
} elseif ($Alpine.IsPresent) {
$projectAssetsZipName = 'linuxAlpineProjectAssetssymbols.zip'
$buildParams.Add("Runtime", 'alpine-x64')
} else {
# make the artifact name unique
$projectAssetsZipName = "linuxProjectAssets-$((get-date).Ticks)-symbols.zip"
$buildParams.Add("Crossgen", $true)
}
Push-Location
try {
Set-Location $location
Import-Module "$location/build.psm1"
Import-Module "$location/tools/packaging"
Start-PSBuild @buildParams @releaseTagParam
Start-PSBootstrap -Package -NoSudo
if($FxDependent) {
Start-PSPackage -Type 'fxdependent' @releaseTagParam
} elseif ($Alpine) {
Start-PSPackage -Type 'tar-alpine' @releaseTagParam
} else {
Start-PSPackage @releaseTagParam
}
$buildParams = @{ Configuration = 'Release'; PSModuleRestore = $true; Restore = $true }
if ($TarX64) { Start-PSPackage -Type tar @releaseTagParam }
if ($FxDependent.IsPresent) {
$projectAssetsZipName = 'linuxFxDependantProjectAssetssymbols.zip'
$buildParams.Add("Runtime", "fxdependent")
} elseif ($Alpine.IsPresent) {
$projectAssetsZipName = 'linuxAlpineProjectAssetssymbols.zip'
$buildParams.Add("Runtime", 'alpine-x64')
} else {
# make the artifact name unique
$projectAssetsZipName = "linuxProjectAssets-$((get-date).Ticks)-symbols.zip"
$buildParams.Add("Crossgen", $true)
}
if ($TarArm) {
## Build 'linux-arm' and create 'tar.gz' package for it.
## Note that 'linux-arm' can only be built on Ubuntu environment.
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm @releaseTagParam
}
Start-PSBuild @buildParams @releaseTagParam
if ($TarArm64) {
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm64 -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm64 @releaseTagParam
if ($FxDependent) {
Start-PSPackage -Type 'fxdependent' @releaseTagParam -LTS:$LTS
} elseif ($Alpine) {
Start-PSPackage -Type 'tar-alpine' @releaseTagParam -LTS:$LTS
} else {
Start-PSPackage @releaseTagParam -LTS:$LTS
}
if ($TarX64) { Start-PSPackage -Type tar @releaseTagParam -LTS:$LTS }
if ($TarArm) {
## Build 'linux-arm' and create 'tar.gz' package for it.
## Note that 'linux-arm' can only be built on Ubuntu environment.
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm @releaseTagParam -LTS:$LTS
}
if ($TarArm64) {
Start-PSBuild -Configuration Release -Restore -Runtime linux-arm64 -PSModuleRestore @releaseTagParam
Start-PSPackage -Type tar-arm64 @releaseTagParam -LTS:$LTS
}
} finally {
Pop-Location
}
}
finally
{
Pop-Location
BuildPackages
if ($LTS) {
Write-Verbose -Verbose "Packaging LTS"
BuildPackages -LTS
}
$linuxPackages = Get-ChildItem "$location/powershell*" -Include *.deb,*.rpm,*.tar.gz

View file

@ -39,6 +39,7 @@ jobs:
- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTagVar) -Name '$(build)'
displayName: 'Build and package'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))

View file

@ -36,10 +36,20 @@ jobs:
$zipFile = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip"
Compress-Archive -Path "$(System.ArtifactsDirectory)\results\powershell-$(Version)-osx-x64.pkg" -Destination $zipFile
Write-Host $zipFile
$ltsPkgPath = "$(System.ArtifactsDirectory)\results\powershell-lts-$(Version)-osx-x64.pkg"
if(Test-Path $ltsPkgPath)
{
$ltsZipFile = "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-x64.zip"
Compress-Archive -Path $ltsPkgPath -Destination $ltsZipFile
Write-Host $ltsZipFile
}
displayName: 'Compress macOS Package'
- powershell: |
tools/releaseBuild/generatePackgeSigning.ps1 -MacDeveloperFiles "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip" -path "$(System.ArtifactsDirectory)\package.xml"
$pkgFiles = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip", "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-x64.zip"
tools/releaseBuild/generatePackgeSigning.ps1 -MacDeveloperFiles $pkgFiles -path "$(System.ArtifactsDirectory)\package.xml"
displayName: 'Generate macOS Package Signing Xml'
- powershell: |
@ -68,7 +78,7 @@ jobs:
$destination = "$(System.ArtifactsDirectory)\azureMacOs"
New-Item -Path $destination -Type Directory
$zipPath = dir "$(Build.StagingDirectory)\signedMacOSPackages\powershell-*.zip" -Recurse | select-object -expandproperty fullname
Expand-Archive -Path $zipPath -DestinationPath $destination
foreach ($z in $zipPath) { Expand-Archive -Path $z -DestinationPath $destination }
$targzPath = dir "$(System.ArtifactsDirectory)\*.tar.gz" -Recurse | select-object -expandproperty fullname
Copy-Item -Path $targzPath -Destination $destination
displayName: 'Extract and copy macOS artifacts for upload'

View file

@ -32,9 +32,20 @@ param (
$repoRoot = $location
if ($Build.IsPresent) {
$releaseTagParam = @{}
$releaseTagParam = @{ }
if ($ReleaseTag) {
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
#Remove the initial 'v' from the ReleaseTag
$version = $ReleaseTag -replace '^v'
$semVersion = [System.Management.Automation.SemanticVersion] $version
## All even minor versions are LTS
$LTS = if ( $semVersion.PreReleaseLabel -eq $null -and $semVersion.Minor % 2 -eq 0) {
$true
} else {
$false
}
}
}
@ -57,6 +68,13 @@ try {
switch ($ExtraPackage) {
"tar" { Start-PSPackage -Type tar @releaseTagParam }
}
if ($LTS) {
Start-PSPackage @releaseTagParam -LTS
switch ($ExtraPackage) {
"tar" { Start-PSPackage -Type tar @releaseTagParam -LTS }
}
}
}
} finally {
Pop-Location

View file

@ -58,9 +58,10 @@ function New-BuildInfoJson {
$branchOnly = $Branch -replace '^refs/heads/';
$branchOnly = $branchOnly -replace '[_\-]'
$isDaily = $false
if($ReleaseTag -eq 'fromBranch' -or !$ReleaseTag)
{
$isDaily = $false
# Branch is named release-<semver>
if($Branch -match '^.*(release[-/])')
{