From 414a867757d25403aa546280d6ed4b05c0ee6563 Mon Sep 17 00:00:00 2001 From: Malin Fossum Date: Thu, 12 Nov 2026 10:38:37 +0100 Subject: [PATCH] Add Brave.BraveOrigin --- Tasks/Brave.BraveOrigin/Config.yaml | 3 ++ Tasks/Brave.BraveOrigin/Script.ps1 | 84 +++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Tasks/Brave.BraveOrigin/Config.yaml create mode 100644 Tasks/Brave.BraveOrigin/Script.ps1 diff --git a/Tasks/Brave.BraveOrigin/Config.yaml b/Tasks/Brave.BraveOrigin/Config.yaml new file mode 100644 index 0000000000..b5ef1d32bd --- /dev/null +++ b/Tasks/Brave.BraveOrigin/Config.yaml @@ -0,0 +1,3 @@ +Type: PackageTask +WinGetIdentifier: Brave.BraveOrigin +Skip: false diff --git a/Tasks/Brave.BraveOrigin/Script.ps1 b/Tasks/Brave.BraveOrigin/Script.ps1 new file mode 100644 index 0000000000..dae64570af --- /dev/null +++ b/Tasks/Brave.BraveOrigin/Script.ps1 @@ -0,0 +1,84 @@ +$Object1 = Invoke-GitHubApi -Uri 'https://api.github.com/repos/brave/brave-browser/releases/latest' + +# Version +$this.CurrentState.Version = "$([regex]::Match($Object1.name, 'Chromium (\d+)').Groups[1].Value).$([regex]::Match($Object1.name, 'v(\d+(?:\.\d+)+)').Groups[1].Value)" + +# Installer +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x86' + Scope = 'user' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('Setup32.exe') -and $_.name -match 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x86' + Scope = 'machine' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('Setup32.exe') -and $_.name -notmatch 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x64' + Scope = 'user' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('Setup.exe') -and $_.name -match 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x64' + Scope = 'machine' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('Setup.exe') -and $_.name -notmatch 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'arm64' + Scope = 'user' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('SetupArm64.exe') -and $_.name -match 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'arm64' + Scope = 'machine' + InstallerUrl = $Object1.assets.Where({ $_.name -match 'BraveOriginStandalone' -and $_.name.EndsWith('SetupArm64.exe') -and $_.name -notmatch 'Silent' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} + +switch -Regex ($this.Check()) { + 'New|Changed|Updated' { + try { + # ReleaseTime + $this.CurrentState.ReleaseTime = $Object1.published_at.ToUniversalTime() + + # ReleaseNotesUrl (en-US) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotesUrl' + Value = $Object1.html_url + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + try { + $Object2 = Invoke-RestMethod -Uri 'https://raw.githubusercontent.com/brave/brave-browser/master/CHANGELOG_DESKTOP.md' | Convert-MarkdownToHtml + + $ReleaseNotesTitleNode = $Object2.SelectSingleNode("/h2[contains(.//text(), '$($this.CurrentState.Version.Split('.')[1..3] -join '.')')]") + if ($ReleaseNotesTitleNode) { + $ReleaseNotesNodes = for ($Node = $ReleaseNotesTitleNode.NextSibling; $Node -and $Node.Name -ne 'h2'; $Node = $Node.NextSibling) { $Node } + # ReleaseNotes (en-US) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotes' + Value = ($ReleaseNotesNodes | Get-TextContent) -replace 'Released \d{4}-\d{1,2}-\d{1,2}\n' | Format-Text + } + } else { + $this.Log("No ReleaseNotes (en-US) for version $($this.CurrentState.Version)", 'Warning') + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + $this.Print() + $this.Write() + } + 'Changed|Updated' { + $this.Message() + } + 'Updated' { + $this.Submit() + } +}