From 355d79f16e8751a5b70506a768d0d9cd7cce251c Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 8 Jul 2020 17:41:31 +0300 Subject: [PATCH] Add unstable version support --- packages-generation/manifest-generator.ps1 | 1 + packages-generation/manifest-utils.psm1 | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages-generation/manifest-generator.ps1 b/packages-generation/manifest-generator.ps1 index a1d8397..883348a 100644 --- a/packages-generation/manifest-generator.ps1 +++ b/packages-generation/manifest-generator.ps1 @@ -31,5 +31,6 @@ $configuration = Read-ConfigurationFile -Filepath $ConfigurationFile $gitHubApi = Get-GitHubApi -AccountName $GitHubRepositoryOwner -ProjectName $GitHubRepositoryName -AccessToken $GitHubAccessToken $releases = $gitHubApi.GetReleases() + $versionIndex = Build-VersionsManifest -Releases $releases -Configuration $configuration $versionIndex | ConvertTo-Json -Depth 5 | Out-File $OutputFile -Encoding UTF8NoBOM -Force diff --git a/packages-generation/manifest-utils.psm1 b/packages-generation/manifest-utils.psm1 index 2d4ef00..08bc3e5 100644 --- a/packages-generation/manifest-utils.psm1 +++ b/packages-generation/manifest-utils.psm1 @@ -35,8 +35,8 @@ function Get-VersionFromRelease { ) # Release name can contain additional information after ':' so filter it [string]$releaseName = $Release.name.Split(':')[0] - [Version]$version = $null - if (![Version]::TryParse($releaseName, [ref]$version)) { + [Semver]$version = $null + 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) )" } @@ -57,21 +57,22 @@ function Build-VersionsManifest { continue } - [Version]$version = Get-VersionFromRelease $release + [Semver]$version = Get-VersionFromRelease $release $versionKey = $version.ToString() if ($versionsHash.ContainsKey($versionKey)) { continue } - + + $stable = $version.PreReleaseLabel ? $false : $true $versionsHash.Add($versionKey, [PSCustomObject]@{ version = $versionKey - stable = $true + stable = $stable release_url = $release.html_url files = $release.assets | ForEach-Object { New-AssetItem -ReleaseAsset $_ -Configuration $Configuration } }) } # 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 } } \ No newline at end of file