From ce005c70246ec3afd4726556d21aa10ed40fa725 Mon Sep 17 00:00:00 2001 From: Dragon1573 <49941141+Dragon1573@users.noreply.github.com> Date: Tue, 24 Jun 2025 22:44:03 +0800 Subject: [PATCH 1/2] New package: MichalTrojnara.osslsigncode --- Tasks/MichalTrojnara.osslsigncode/Config.yaml | 6 +++ Tasks/MichalTrojnara.osslsigncode/Script.ps1 | 52 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Tasks/MichalTrojnara.osslsigncode/Config.yaml create mode 100644 Tasks/MichalTrojnara.osslsigncode/Script.ps1 diff --git a/Tasks/MichalTrojnara.osslsigncode/Config.yaml b/Tasks/MichalTrojnara.osslsigncode/Config.yaml new file mode 100644 index 0000000000..3c50aa0d35 --- /dev/null +++ b/Tasks/MichalTrojnara.osslsigncode/Config.yaml @@ -0,0 +1,6 @@ +Type: PackageTask +WinGetIdentifier: MichalTrojnara.osslsigncode +Skip: false +Notes: > + This is a temporary resolution. Already asked the original author if he/she is + willing to integrate WinGet Releaser into his/her GitHub Workflows. diff --git a/Tasks/MichalTrojnara.osslsigncode/Script.ps1 b/Tasks/MichalTrojnara.osslsigncode/Script.ps1 new file mode 100644 index 0000000000..5cbe9b1441 --- /dev/null +++ b/Tasks/MichalTrojnara.osslsigncode/Script.ps1 @@ -0,0 +1,52 @@ +############################################################################### +# NOTES: Uses Tasks/PixPin.PixPin.Beta/Script.ps1 as the template. +############################################################################### + +# Fetch the latest assets URL. +# NOTES: It seems the runner provides built-in GitHub CLI. We can use it to bypass API Rate Limits. +$LatestInfo = gh api '/repos/mtrojnar/osslsigncode/releases' --jq '.[0]' | ConvertFrom-Json + +# Version +$this.CurrentState.Version = $LatestInfo.tag_name + +# Installer +$LatestAsset = $LatestInfo.assets | Where-Object -Property name -Like '*windows*' +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x64' + InstallerUrl = $LatestAsset.browser_download_url +} + +switch -Regex ($this.Check()) { + 'New|Changed|Updated' { + try { + # Release Time + $this.CurrentState.ReleaseTime = $LatestAsset.updated_at.toUniversalTime() + + # Release Notes (en-US) + $ReleaseNotesObject = $LatestInfo.body | Convert-MarkdownToHtml + $this.CurrentState.Locale += [ordered]@{ + Locale = 'en-US' + Key = 'ReleaseNotes' + Value = $ReleaseNotesObject | Get-TextContent | Format-Text + } + + # Release Notes Url + $this.CurrentState.Locale += [ordered]@{ + Key = 'ReleaseNotesUrl' + Value = $LatestInfo.html_url + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + $this.Print() + $this.Write() + } + 'Changed|Updated' { + $this.Message() + } + 'Updated' { + $this.Submit() + } +} From 9907df36b983c6a93f6c0394ac6cc20013158486 Mon Sep 17 00:00:00 2001 From: Charlie Chen <56779163+SpecterShell@users.noreply.github.com> Date: Wed, 25 Jun 2025 17:10:47 +0800 Subject: [PATCH 2/2] Update Script.ps1 --- Tasks/MichalTrojnara.osslsigncode/Script.ps1 | 37 ++++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Tasks/MichalTrojnara.osslsigncode/Script.ps1 b/Tasks/MichalTrojnara.osslsigncode/Script.ps1 index 5cbe9b1441..bacd1e09fb 100644 --- a/Tasks/MichalTrojnara.osslsigncode/Script.ps1 +++ b/Tasks/MichalTrojnara.osslsigncode/Script.ps1 @@ -1,39 +1,38 @@ -############################################################################### -# NOTES: Uses Tasks/PixPin.PixPin.Beta/Script.ps1 as the template. -############################################################################### +$RepoOwner = 'mtrojnar' +$RepoName = 'osslsigncode' -# Fetch the latest assets URL. -# NOTES: It seems the runner provides built-in GitHub CLI. We can use it to bypass API Rate Limits. -$LatestInfo = gh api '/repos/mtrojnar/osslsigncode/releases' --jq '.[0]' | ConvertFrom-Json +$Object1 = Invoke-GitHubApi -Uri "https://api.github.com/repos/${RepoOwner}/${RepoName}/releases/latest" # Version -$this.CurrentState.Version = $LatestInfo.tag_name +$this.CurrentState.Version = $Object1.tag_name -creplace '^v' # Installer -$LatestAsset = $LatestInfo.assets | Where-Object -Property name -Like '*windows*' $this.CurrentState.Installer += [ordered]@{ Architecture = 'x64' - InstallerUrl = $LatestAsset.browser_download_url + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.zip') -and $_.name.Contains('windows') -and $_.name.Contains('x64') }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri } switch -Regex ($this.Check()) { 'New|Changed|Updated' { try { - # Release Time - $this.CurrentState.ReleaseTime = $LatestAsset.updated_at.toUniversalTime() + # ReleaseTime + $this.CurrentState.ReleaseTime = $Object1.published_at.ToUniversalTime() - # Release Notes (en-US) - $ReleaseNotesObject = $LatestInfo.body | Convert-MarkdownToHtml - $this.CurrentState.Locale += [ordered]@{ - Locale = 'en-US' - Key = 'ReleaseNotes' - Value = $ReleaseNotesObject | Get-TextContent | Format-Text + 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') } - # Release Notes Url + # ReleaseNotesUrl $this.CurrentState.Locale += [ordered]@{ Key = 'ReleaseNotesUrl' - Value = $LatestInfo.html_url + Value = $Object1.html_url } } catch { $_ | Out-Host