Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 72 additions & 44 deletions 116 tools/releaseBuild/vstsbuild.ps1
Original file line number Diff line number Diff line change
@@ -1,59 +1,87 @@
param(
[Parameter(ParameterSetName='Build')]
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
[string]$ReleaseTag,

[ValidateSet('win7-x86','win7-x64','win7-x86-symbols','win7-x64-symbols','ubuntu.14.04','ubuntu.16.04','centos.7')]
[String]
$Name
[string]$ReleaseTag
)

$ErrorActionPreference = 'Stop'
DynamicParam {
# Add a dynamic parameter '-Name' which specifies the name of the build to run

# Get the names of the builds.
$buildJsonPath = (Join-Path -path $PSScriptRoot -ChildPath 'build.json')
$build = Get-Content -Path $buildJsonPath | ConvertFrom-Json
$names = @($build.Windows.Name)
foreach($name in $build.Linux.Name)
{
$names += $name
}

$psReleaseBranch = 'master'
$psReleaseFork = 'PowerShell'
$location = Join-Path -Path $PSScriptRoot -ChildPath 'PSRelease'
if(Test-Path $location)
{
Remove-Item -Path $location -Recurse -Force
# Create the parameter attributs
$ParameterAttr = New-Object "System.Management.Automation.ParameterAttribute"
$ValidateSetAttr = New-Object "System.Management.Automation.ValidateSetAttribute" -ArgumentList $names
$Attributes = New-Object "System.Collections.ObjectModel.Collection``1[System.Attribute]"
$Attributes.Add($ParameterAttr) > $null
$Attributes.Add($ValidateSetAttr) > $null

# Create the parameter
$Parameter = New-Object "System.Management.Automation.RuntimeDefinedParameter" -ArgumentList ("Name", [string], $Attributes)
$Dict = New-Object "System.Management.Automation.RuntimeDefinedParameterDictionary"
$Dict.Add("Name", $Parameter) > $null
return $Dict
}

$gitBinFullPath = (Get-Command -Name git).Source
if (-not $gitBinFullPath)
{
throw "Git is required to proceed. Install from 'https://git-scm.com/download/win'"
Begin {
$Name = $PSBoundParameters['Name']
}

Write-Verbose "cloning -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git" -verbose
& $gitBinFullPath clone -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git $location
End {
$ErrorActionPreference = 'Stop'

Push-Location -Path $PWD.Path
try{
Set-Location $location
& $gitBinFullPath submodule update --init --recursive --quiet
}
finally
{
Pop-Location
}
$psReleaseBranch = 'master'
$psReleaseFork = 'PowerShell'
$location = Join-Path -Path $PSScriptRoot -ChildPath 'PSRelease'
if(Test-Path $location)
{
Remove-Item -Path $location -Recurse -Force
}

$unresolvedRepoRoot = Join-Path -Path $PSScriptRoot '../..'
$resolvedRepoRoot = (Resolve-Path -Path $unresolvedRepoRoot).ProviderPath
$gitBinFullPath = (Get-Command -Name git).Source
if (-not $gitBinFullPath)
{
throw "Git is required to proceed. Install from 'https://git-scm.com/download/win'"
}

try
{
Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose
Import-Module "$location/vstsBuild" -Force
Import-Module "$location/dockerBasedBuild" -Force
Clear-VstsTaskState
Write-Verbose "cloning -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git" -verbose
& $gitBinFullPath clone -b $psReleaseBranch --quiet https://github.com/$psReleaseFork/PSRelease.git $location

Invoke-Build -RepoPath $resolvedRepoRoot -BuildJsonPath './tools/releaseBuild/build.json' -Name $Name -Parameters $PSBoundParameters
}
catch
{
Write-VstsError -Error $_
}
finally{
Write-VstsTaskState
exit 0
Push-Location -Path $PWD.Path
try{
Set-Location $location
& $gitBinFullPath submodule update --init --recursive --quiet
}
finally
{
Pop-Location
}

$unresolvedRepoRoot = Join-Path -Path $PSScriptRoot '../..'
$resolvedRepoRoot = (Resolve-Path -Path $unresolvedRepoRoot).ProviderPath

try
{
Write-Verbose "Starting build at $resolvedRepoRoot ..." -Verbose
Import-Module "$location/vstsBuild" -Force
Import-Module "$location/dockerBasedBuild" -Force
Clear-VstsTaskState

Invoke-Build -RepoPath $resolvedRepoRoot -BuildJsonPath './tools/releaseBuild/build.json' -Name $Name -Parameters $PSBoundParameters
}
catch
{
Write-VstsError -Error $_
}
finally{
Write-VstsTaskState
exit 0
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.