-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.ps1
39 lines (31 loc) · 1.14 KB
/
helpers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Import-Module PowerShellForGitHub
$owner = 'localsend'
$repository = 'localsend'
function Get-LatestStableVersion {
$latestRelease = (Get-GitHubRelease -OwnerName $owner -RepositoryName $repository -Latest)[0]
return $latestRelease.tag_name.Substring(1)
}
function Get-SoftwareUri($Version) {
if ($null -eq $Version) {
# Default to latest stable version
$release = (Get-GitHubRelease -OwnerName $owner -RepositoryName $repository -Latest)[0]
}
else {
$release = Get-GitHubRelease -OwnerName $owner -RepositoryName $repository -Tag "v$($Version.ToString())"
}
$releaseAssets = Get-GitHubReleaseAsset -OwnerName $owner -RepositoryName $repository -Release $release.ID
$windowsArchiveAsset = $null
foreach ($asset in $releaseAssets) {
if ($asset.name -match 'LocalSend-([\d\.]+)-windows(-x86-64)?\.zip$') {
$windowsArchiveAsset = $asset
break
}
else {
continue
}
}
if ($null -eq $windowsArchiveAsset) {
throw 'Cannot find published Windows archive asset!'
}
return $windowsArchiveAsset.browser_download_url
}