-
Notifications
You must be signed in to change notification settings - Fork 8.1k
migrate the mac offical binary build to VSTS mac hosted preview #6363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
26447e3
Add script to create /PowerShell with correct permissions
TravisEz13 863d4d7
Add wrapper for building in VSTS using Hosted mac agent
TravisEz13 db54281
Add build definition
TravisEz13 d2479dd
remove zip extra package
TravisEz13 435a3b5
address PR feedback
TravisEz13 33065c3
add comments to explain the format
TravisEz13 dc72c67
add comments about why I'm using sudo to install gems
TravisEz13 08d64f3
rename linuxPackage(s) to macPackage(s)
TravisEz13 f299c55
format script
TravisEz13 bc4bacc
fix typo
TravisEz13 9cbeaac
fix various issues with comment
TravisEz13 da8e356
Minor update.
daxian-dbw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the VM is reused, we should use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VM is reused but not the process. |
||
| 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 | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pwsh -command ".\PowerShellPackageVsts.ps1 $*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the VM is reused, we should use
-ForceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VM is reused but not the process.