From fbad9d6b0ee7598cf0398d5ecf58c630dee5d991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9D=A4=E6=98=AF=E7=BA=B1=E9=9B=BE=E9=85=B1=E5=93=9F?= =?UTF-8?q?=EF=BD=9E?= <49941141+Dragon1573@users.noreply.github.com> Date: Sat, 27 Jun 2026 18:17:54 +0800 Subject: [PATCH 1/2] feat(tasks): add Chill-Astro.TMM update task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com> --- Tasks/Chill-Astro.TMM/Config.yaml | 3 ++ Tasks/Chill-Astro.TMM/Script.ps1 | 51 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Tasks/Chill-Astro.TMM/Config.yaml create mode 100644 Tasks/Chill-Astro.TMM/Script.ps1 diff --git a/Tasks/Chill-Astro.TMM/Config.yaml b/Tasks/Chill-Astro.TMM/Config.yaml new file mode 100644 index 0000000000..b4ef36e149 --- /dev/null +++ b/Tasks/Chill-Astro.TMM/Config.yaml @@ -0,0 +1,3 @@ +Type: PackageTask +WinGetIdentifier: Chill-Astro.TMM +Skip: false diff --git a/Tasks/Chill-Astro.TMM/Script.ps1 b/Tasks/Chill-Astro.TMM/Script.ps1 new file mode 100644 index 0000000000..cbcc542421 --- /dev/null +++ b/Tasks/Chill-Astro.TMM/Script.ps1 @@ -0,0 +1,51 @@ +$RepoOwner = 'Chill-Astro' +$RepoName = 'Trust-My-Msix' + +$Object1 = Invoke-GitHubApi -Uri "https://api.github.com/repos/${RepoOwner}/${RepoName}/releases/latest" + +# Version +$this.CurrentState.Version = $Object1.tag_name -creplace '^v' + +# Installer +$this.CurrentState.Installer += [ordered]@{ + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} + +switch -Regex ($this.Check()) { + 'New|Changed|Updated' { + try { + # ReleaseTime + $this.CurrentState.ReleaseTime = $Object1.published_at.ToUniversalTime() + + if (-not [string]::IsNullOrWhiteSpace($Object1.body)) { + # ReleaseNotes (en-US) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotes' + Value = $Object1.body | Convert-MarkdownToHtml -Extensions 'advanced', 'emojis', 'hardlinebreak' | Get-TextContent | Format-Text + } + } else { + $this.Log("No ReleaseNotes (en-US) for version $($this.CurrentState.Version)", 'Warning') + } + + # ReleaseNotesUrl (en-US) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotesUrl' + Value = $Object1.html_url + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + $this.Print() + $this.Write() + } + 'Changed|Updated' { + $this.Message() + } + 'Updated' { + $this.Submit() + } +} From e3a19a1baa6b6f3c227cbff7a5c9bca0367b33e9 Mon Sep 17 00:00:00 2001 From: SpecterShell <56779163+SpecterShell@users.noreply.github.com> Date: Sun, 5 Jul 2026 00:58:10 +0800 Subject: [PATCH 2/2] Refactor --- Tasks/Chill-Astro.TMM/Script.ps1 | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Tasks/Chill-Astro.TMM/Script.ps1 b/Tasks/Chill-Astro.TMM/Script.ps1 index cbcc542421..e0d126c2a5 100644 --- a/Tasks/Chill-Astro.TMM/Script.ps1 +++ b/Tasks/Chill-Astro.TMM/Script.ps1 @@ -1,14 +1,16 @@ -$RepoOwner = 'Chill-Astro' -$RepoName = 'Trust-My-Msix' - -$Object1 = Invoke-GitHubApi -Uri "https://api.github.com/repos/${RepoOwner}/${RepoName}/releases/latest" +$Object1 = Invoke-GitHubApi -Uri 'https://api.github.com/repos/Chill-Astro/Trust-My-Msix/releases/latest' # Version -$this.CurrentState.Version = $Object1.tag_name -creplace '^v' +$this.CurrentState.Version = $Object1.tag_name -replace '^v' # Installer $this.CurrentState.Installer += [ordered]@{ - InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri + InstallerType = 'portable' + InstallerUrl = $Object1.assets.Where({ $_.name -eq 'TMM.exe' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + InstallerType = 'inno' + InstallerUrl = $Object1.assets.Where({ $_.name -eq 'Setup.exe' }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri } switch -Regex ($this.Check()) { @@ -18,11 +20,18 @@ switch -Regex ($this.Check()) { $this.CurrentState.ReleaseTime = $Object1.published_at.ToUniversalTime() if (-not [string]::IsNullOrWhiteSpace($Object1.body)) { - # ReleaseNotes (en-US) - $this.CurrentState.Locale += [ordered]@{ - Locale = 'en-US' - Key = 'ReleaseNotes' - Value = $Object1.body | Convert-MarkdownToHtml -Extensions 'advanced', 'emojis', 'hardlinebreak' | Get-TextContent | Format-Text + $ReleaseNotesObject = $Object1.body | Convert-MarkdownToHtml -Extensions 'advanced', 'emojis', 'hardlinebreak' + $ReleaseNotesTitleNode = $ReleaseNotesObject.SelectSingleNode('./h3[contains(., "Release Notes") or contains(., "Changes")]') + if ($ReleaseNotesTitleNode) { + $ReleaseNotesNodes = for ($Node = $ReleaseNotesTitleNode.NextSibling; $Node -and $Node.Name -notin @('h1', 'h2', 'h3', 'hr'); $Node = $Node.NextSibling) { $Node } + # ReleaseNotes (en-US) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotes' + Value = $ReleaseNotesNodes | Get-TextContent | Format-Text + } + } else { + $this.Log("No ReleaseNotes (en-US) for version $($this.CurrentState.Version)", 'Warning') } } else { $this.Log("No ReleaseNotes (en-US) for version $($this.CurrentState.Version)", 'Warning')