Skip to content

Commit

Permalink
(brave) update++
Browse files Browse the repository at this point in the history
  • Loading branch information
majkinetor committed Jun 5, 2019
1 parent 2e63f0c commit 4718312
Showing 1 changed file with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions automatic/brave/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,46 @@ $releases = 'https://github.com/brave/brave-browser/releases'

function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing
$url32 = $download_page.links | ? { $_.href -match 'StandaloneSilentSetup32.exe$' } | select -First 1 -expand href
$url64 = $download_page.links | ? { $_.href -match 'StandaloneSilentSetup.exe$' } | select -First 1 -expand href
$url32_b = $download_page.links | ? { $_.href -match 'SilentBetaSetup32.exe$' } | select -First 1 -expand href
$url64_b = $download_page.links | ? { $_.href -match 'SilentBetaSetup.exe$' } | select -First 1 -expand href

if (!$url32 -and !$url32_b) {
Write-Host "No stable and no beta release is available (Nightly not supported)..."
return "ignore"
}

$version = $url32 -split '/v?' | select -Skip 1 -Last 1

$domain = $releases -split '(?<=//.+)/' | select -First 1
$url32 = $download_page.links | ? href -match 'StandaloneSilentSetup32.exe$' | select -First 1 -expand href
$url64 = $download_page.links | ? href -match 'StandaloneSilentSetup.exe$' | select -First 1 -expand href
$url32_b = $download_page.links | ? href -match 'SilentBetaSetup32.exe$' | select -First 1 -expand href
$url64_b = $download_page.links | ? href -match 'SilentBetaSetup.exe$' | select -First 1 -expand href
$version = $url32 -split '/v?' | select -Skip 1 -Last 1
$version_b = $url32_b -split '/v?' | select -Skip 1 -Last 1

$streams = @{
'stable' = @{
URL32 = 'https://github.com' + $url32
URL64 = 'https://github.com' + $url64
stable = @{
URL32 = $domain + $url32
URL64 = $domain + $url64
Version = $version
Title = 'Brave Browser'
IconUrl = 'https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-coreteampackages@a23ca30653/icons/brave.svg'
}
}


if ($version_b) {
# if there is no beta version, this means it is a nightly release. We skip those as it misbehaves with beta versioning
$streams.Add('beta', @{
URL32 = 'https://github.com' + $url32_b
URL64 = 'https://github.com' + $url64_b
beta = @{
URL32 = $domain + $url32_b
URL64 = $domain + $url64_b
Version = $version_b + '-beta'
Title = 'Brave Browser (Beta)'
IconUrl = 'https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-coreteampackages@a23ca30653/icons/brave-beta.svg'
})
}
}
else {
$streams.Add('beta', 'ignore')

if (!$url64 -and !$url64_b) {
Write-Host "No stable and no beta release is available (Nightly not supported)..."
return "ignore"
}

if (!$url64) { $streams.stable = 'ignore'; Write-Host "No stable release is available" }
if (!$url64_b) { $streams.beta = 'ignore'; Write-Host "No beta release is available" }
@{ streams = $streams }
}

function global:au_BeforeUpdate {
if ($Latest.Title -like '*Beta*') {
cp "$PSScriptRoot\README-beta.md" "$PSScriptRoot\README.md" -Force
}
else {
cp "$PSScriptRoot\README-release.md" "$PSScriptRoot\README.md" -Force
}
$stream_readme = if ($Latest.Title -like '*Beta*') {'README-beta.md'} else {'README-release.md'}
cp $stream_readme $PSScriptRoot\README.md -Force
Get-RemoteFiles -Purge -NoSuffix
}

Expand Down

0 comments on commit 4718312

Please sign in to comment.