Add unstable version support

pull/8/head
Vladimir Safonkin 5 years ago
parent 8523adc672
commit 355d79f16e

@ -31,5 +31,6 @@ $configuration = Read-ConfigurationFile -Filepath $ConfigurationFile
$gitHubApi = Get-GitHubApi -AccountName $GitHubRepositoryOwner -ProjectName $GitHubRepositoryName -AccessToken $GitHubAccessToken $gitHubApi = Get-GitHubApi -AccountName $GitHubRepositoryOwner -ProjectName $GitHubRepositoryName -AccessToken $GitHubAccessToken
$releases = $gitHubApi.GetReleases() $releases = $gitHubApi.GetReleases()
$versionIndex = Build-VersionsManifest -Releases $releases -Configuration $configuration $versionIndex = Build-VersionsManifest -Releases $releases -Configuration $configuration
$versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force $versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force

@ -35,8 +35,8 @@ function Get-VersionFromRelease {
) )
# Release name can contain additional information after ':' so filter it # Release name can contain additional information after ':' so filter it
[string]$releaseName = $Release.name.Split(':')[0] [string]$releaseName = $Release.name.Split(':')[0]
[Version]$version = $null [Semver]$version = $null
if (![Version]::TryParse($releaseName, [ref]$version)) { if (![Semver]::TryParse($releaseName, [ref]$version)) {
throw "Release '$($Release.id)' has invalid title '$($Release.name)'. It can't be parsed as version. ( $($Release.html_url) )" throw "Release '$($Release.id)' has invalid title '$($Release.name)'. It can't be parsed as version. ( $($Release.html_url) )"
} }
@ -57,21 +57,22 @@ function Build-VersionsManifest {
continue continue
} }
[Version]$version = Get-VersionFromRelease $release [Semver]$version = Get-VersionFromRelease $release
$versionKey = $version.ToString() $versionKey = $version.ToString()
if ($versionsHash.ContainsKey($versionKey)) { if ($versionsHash.ContainsKey($versionKey)) {
continue continue
} }
$stable = $version.PreReleaseLabel ? $false : $true
$versionsHash.Add($versionKey, [PSCustomObject]@{ $versionsHash.Add($versionKey, [PSCustomObject]@{
version = $versionKey version = $versionKey
stable = $true stable = $stable
release_url = $release.html_url release_url = $release.html_url
files = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration } files = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration }
}) })
} }
# Sort versions by descending # Sort versions by descending
return $versionsHash.Values | Sort-Object -Property @{ Expression = { [Version]$_.version }; Descending = $true } return $versionsHash.Values | Sort-Object -Property @{ Expression = { [Semver]$_.version }; Descending = $true }
} }
Loading…
Cancel
Save