mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
migrate the mac offical binary build to VSTS mac hosted preview (#6363)
create a PowerShellPackage...ps1 that works with these VMs (vs our custom VM) create a script to create the \powershell folder with correct permissions a YML VSTS build definition
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
# PowerShell Script to build and package PowerShell from specified form and branch
|
||||
# Script is intented to use in Docker containers
|
||||
# Ensure PowerShell is available in the provided image
|
||||
|
||||
param (
|
||||
# Set default location to where VSTS cloned the repository locally.
|
||||
[string] $location = $env:BUILD_REPOSITORY_LOCALPATH,
|
||||
|
||||
# Destination location of the package on docker host
|
||||
[Parameter(Mandatory, ParameterSetName = 'Build')]
|
||||
[string] $destination = '/mnt',
|
||||
|
||||
[Parameter(Mandatory, ParameterSetName = 'Build')]
|
||||
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+(\.\d+)?)?$")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$ReleaseTag,
|
||||
|
||||
[Parameter(ParameterSetName = 'Build')]
|
||||
[ValidateSet("zip", "tar")]
|
||||
[string[]]$ExtraPackage,
|
||||
|
||||
[Parameter(Mandatory, ParameterSetName = 'Bootstrap')]
|
||||
[switch] $BootStrap,
|
||||
|
||||
[Parameter(Mandatory, ParameterSetName = 'Build')]
|
||||
[switch] $Build
|
||||
)
|
||||
|
||||
# We must build in /PowerShell
|
||||
$repoRoot = '/PowerShell'
|
||||
if ($BootStrap.IsPresent) {
|
||||
$repoRoot = $location
|
||||
}
|
||||
|
||||
if ($Build.IsPresent) {
|
||||
# cleanup the folder but don't delete it or the build agent will loose ownership of the folder
|
||||
Write-Verbose -Message "cleaning /PowerShell" -Verbose
|
||||
Get-ChildItem -Path /PowerShell/* -Attributes Hidden, Normal, Directory | Remove-Item -Recurse -Force
|
||||
|
||||
# clone the repository to the location we must build from
|
||||
Write-Verbose -Message "cloning to /PowerShell" -Verbose
|
||||
git clone $location /PowerShell
|
||||
$releaseTagParam = @{}
|
||||
if ($ReleaseTag) {
|
||||
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Push-Location
|
||||
try {
|
||||
Write-Verbose -Message "Init..." -Verbose
|
||||
Set-Location $repoRoot
|
||||
git submodule update --init --recursive --quiet
|
||||
Import-Module "$repoRoot/build.psm1"
|
||||
Import-Module "$repoRoot/tools/packaging"
|
||||
Sync-PSTags -AddRemoteIfMissing
|
||||
|
||||
if ($BootStrap.IsPresent) {
|
||||
Start-PSBootstrap -Package
|
||||
|
||||
# The gem install is run by bootstrap without sudo and fails on macOS.
|
||||
# Run the commands with sudo, to resolve the issue
|
||||
Write-Verbose -Message "Installing fpm..." -Verbose
|
||||
Start-NativeExecution { sudo gem install fpm -v 1.8.1 }
|
||||
Write-Verbose -Message "Installing ronn..." -Verbose
|
||||
Start-NativeExecution { sudo gem install ronn }
|
||||
}
|
||||
|
||||
if ($Build.IsPresent) {
|
||||
Start-PSBuild -Crossgen -PSModuleRestore @releaseTagParam
|
||||
|
||||
Start-PSPackage @releaseTagParam
|
||||
switch ($ExtraPackage) {
|
||||
"tar" { Start-PSPackage -Type tar @releaseTagParam }
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
if ($Build.IsPresent) {
|
||||
$macPackages = Get-ChildItem "$repoRoot/powershell*" -Include *.pkg, *.tar.gz
|
||||
foreach ($macPackage in $macPackages) {
|
||||
$filePath = $macPackage.FullName
|
||||
$name = split-path -Leaf -Path $filePath
|
||||
$extension = (Split-Path -Extension -Path $filePath).Replace('.', '')
|
||||
Write-Verbose "Copying $filePath to $destination" -Verbose
|
||||
Write-Host "##vso[artifact.upload containerfolder=results;artifactname=$name]$filePath"
|
||||
Write-Host "##vso[task.setvariable variable=Package-$extension]$filePath"
|
||||
Copy-Item -Path $filePath -Destination $destination -force
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pwsh -command ".\PowerShellPackageVsts.ps1 $*"
|
||||
@@ -0,0 +1,8 @@
|
||||
# print version for diags
|
||||
sw_vers -productVersion
|
||||
|
||||
# create folder
|
||||
sudo mkdir /PowerShell
|
||||
|
||||
# make the current user the owner
|
||||
sudo chown $USER /PowerShell
|
||||
@@ -0,0 +1,30 @@
|
||||
steps:
|
||||
#- task: <task type name>@<version>
|
||||
# inputs:
|
||||
# <task specific inputs>
|
||||
# displayName: '<display name of task>'
|
||||
- task: ShellScript@2
|
||||
inputs:
|
||||
scriptPath: 'tools/releaseBuild/setReleaseTag.sh'
|
||||
args: '-ReleaseTag $(ReleaseTagVar) -Variable "ReleaseTagVar"'
|
||||
displayName: 'Calculate Release Tag'
|
||||
- task: ShellScript@2
|
||||
inputs:
|
||||
scriptPath: 'tools/installpsh-osx.sh'
|
||||
displayName: 'Install pwsh'
|
||||
- task: ShellScript@2
|
||||
inputs:
|
||||
scriptPath: 'tools/releaseBuild/macOS/createPowerShell.sh'
|
||||
displayName: 'Create /PowerShell'
|
||||
- task: ShellScript@2
|
||||
inputs:
|
||||
scriptPath: 'tools/releaseBuild/macOS/PowerShellPackageVsts.sh'
|
||||
args: '-location $(Build.SourcesDirectory) -BootStrap'
|
||||
displayName: 'Bootstrap VM'
|
||||
- task: ShellScript@2
|
||||
inputs:
|
||||
scriptPath: 'tools/releaseBuild/macOS/PowerShellPackageVsts.sh'
|
||||
args: '-ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -ExtraPackage "tar" -location $(Build.SourcesDirectory) -Build'
|
||||
disableAutoCwd: true
|
||||
cwd: 'tools/releaseBuild/macOS'
|
||||
displayName: 'Build and Package'
|
||||
Reference in New Issue
Block a user