mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-12 04:36:49 +00:00
Add unstable version support
This commit is contained in:
@@ -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 }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user