mirror of
https://github.com/actions/python-versions.git
synced 2025-04-07 07:49:41 +00:00
Add support for unstable Python versions (#38)
* Add support of unstable versions to package generation (#2) * Add support of symver versions to Python setup scripts and tests Co-authored-by: Maksim Petrov <47208721+vmapetr@users.noreply.github.com> Co-authored-by: MaksimZhukov <v-mazhuk@microsoft.com> Co-authored-by: Maxim Lobanov <v-malob@microsoft.com>
This commit is contained in:
45
builders/python-version.psm1
Normal file
45
builders/python-version.psm1
Normal file
@ -0,0 +1,45 @@
|
||||
function Convert-Label() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Convert generic semver label to native Python label.
|
||||
#>
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $label
|
||||
)
|
||||
|
||||
switch ($label) {
|
||||
"alpha" { return "a" }
|
||||
"beta" { return "b" }
|
||||
"rc" { return "rc" }
|
||||
default { throw "Invalid version label '$label'" }
|
||||
}
|
||||
}
|
||||
|
||||
function Convert-Version {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Convert generic semver version to native Python version.
|
||||
#>
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[semver] $version,
|
||||
[char] $delimiter = "."
|
||||
)
|
||||
|
||||
$nativeVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, $version.Patch
|
||||
|
||||
if ($version.PreReleaseLabel)
|
||||
{
|
||||
$preReleaseLabel = $version.PreReleaseLabel.Split($delimiter)
|
||||
|
||||
$preReleaseLabelName = Convert-Label -Label $preReleaseLabel[0]
|
||||
$preReleaseLabelVersion = $preReleaseLabel[1]
|
||||
|
||||
$nativeVersion += "${preReleaseLabelName}${preReleaseLabelVersion}"
|
||||
}
|
||||
|
||||
return $nativeVersion
|
||||
}
|
Reference in New Issue
Block a user