Make 'Start-PSBuild' and 'Start-PSPackage' accept a release tag argument (#3921)

This commit is contained in:
Dongbo Wang 2017-06-05 10:21:28 -07:00 committed by GitHub
parent ef33c30219
commit 299a8abb56

View file

@ -128,7 +128,12 @@ function Start-PSBuild {
[switch]$Publish,
[Parameter(ParameterSetName='CoreCLR')]
[switch]$CrossGen
[switch]$CrossGen,
[Parameter(ParameterSetName='CoreCLR')]
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag
)
function Stop-DevPowerShell {
@ -157,8 +162,13 @@ function Start-PSBuild {
}
}
# save Git description to file for PowerShell to include in PSVersionTable
git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60 > "$psscriptroot/powershell.version"
# save git commit id to file for PowerShell to include in PSVersionTable
$gitCommitId = $ReleaseTag
if (-not $gitCommitId) {
# if ReleaseTag is not specified, use 'git describe' to get the commit id
$gitCommitId = git --git-dir="$PSScriptRoot/.git" describe --dirty --abbrev=60
}
$gitCommitId > "$psscriptroot/powershell.version"
# create the telemetry flag file
$null = new-item -force -type file "$psscriptroot/DELETE_ME_TO_DISABLE_CONSOLEHOST_TELEMETRY"
@ -1206,8 +1216,14 @@ function Start-PSBootstrap {
function Start-PSPackage {
[CmdletBinding()]param(
# PowerShell packages use Semantic Versioning http://semver.org/
[Parameter(ParameterSetName = "Version")]
[string]$Version,
[Parameter(ParameterSetName = "ReleaseTag")]
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
[ValidateNotNullOrEmpty()]
[string]$ReleaseTag,
# Package name
[ValidatePattern("^powershell")]
[string]$Name = "powershell",
@ -1253,6 +1269,11 @@ function Start-PSPackage {
throw "Please ensure you have run 'Start-PSBuild -Clean -CrossGen -Runtime $Runtime -Configuration $Configuration'!"
}
# If ReleaseTag is specified, use the given tag to calculate Vesrion
if ($PSCmdlet.ParameterSetName -eq "ReleaseTag") {
$Version = $ReleaseTag -Replace '^v'
}
# Use Git tag if not given a version
if (-not $Version) {
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'