diff --git a/Tasks/PCLCommunity.PCL2-CE.Beta/Config.yaml b/Tasks/PCLCommunity.PCL2-CE.Beta/Config.yaml new file mode 100644 index 0000000000..4be3af9eb3 --- /dev/null +++ b/Tasks/PCLCommunity.PCL2-CE.Beta/Config.yaml @@ -0,0 +1,3 @@ +Type: PackageTask +WinGetIdentifier: PCLCommunity.PCL2-CE.Beta +Skip: false diff --git a/Tasks/PCLCommunity.PCL2-CE.Beta/Script.ps1 b/Tasks/PCLCommunity.PCL2-CE.Beta/Script.ps1 new file mode 100644 index 0000000000..30a5203239 --- /dev/null +++ b/Tasks/PCLCommunity.PCL2-CE.Beta/Script.ps1 @@ -0,0 +1,53 @@ +$Object1 = (Invoke-GitHubApi -Uri "https://api.github.com/repos/PCL-Community/PCL-CE/releases").Where({ $_.prerelease -eq $true -and $_.tag_name.Contains('beta') }, 'First')[0] + +# Version +$this.CurrentState.Version = $Object1.tag_name -replace '^v' + +# Installer +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x64' + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') -and $_.name.Contains('x64') }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'arm64' + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') -and $_.name.Contains('ARM64') }, '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 (zh-CN) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'zh-CN' + Key = 'ReleaseNotes' + Value = $Object1.body | Convert-MarkdownToHtml -Extensions 'advanced', 'emojis', 'hardlinebreak' | Get-TextContent | Format-Text + } + } else { + $this.Log("No ReleaseNotes (zh-CN) for version $($this.CurrentState.Version)", 'Warning') + } + + # ReleaseNotesUrl (zh-CN) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'zh-CN' + Key = 'ReleaseNotesUrl' + Value = $Object1.html_url + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + $this.Print() + $this.Write() + } + 'Changed|Updated' { + $this.Message() + } + 'Updated' { + $this.Submit() + } +} diff --git a/Tasks/PCLCommunity.PCL2-CE/Config.yaml b/Tasks/PCLCommunity.PCL2-CE/Config.yaml new file mode 100644 index 0000000000..0deb592c90 --- /dev/null +++ b/Tasks/PCLCommunity.PCL2-CE/Config.yaml @@ -0,0 +1,3 @@ +Type: PackageTask +WinGetIdentifier: PCLCommunity.PCL2-CE +Skip: false diff --git a/Tasks/PCLCommunity.PCL2-CE/Script.ps1 b/Tasks/PCLCommunity.PCL2-CE/Script.ps1 new file mode 100644 index 0000000000..502f6dc6ea --- /dev/null +++ b/Tasks/PCLCommunity.PCL2-CE/Script.ps1 @@ -0,0 +1,53 @@ +$Object1 = Invoke-GitHubApi -Uri 'https://api.github.com/repos/PCL-Community/PCL-CE/releases/latest' + +# Version +$this.CurrentState.Version = $Object1.tag_name -replace '^v' + +# Installer +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'x64' + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') -and $_.name.Contains('x64') }, 'First')[0].browser_download_url | ConvertTo-UnescapedUri +} +$this.CurrentState.Installer += [ordered]@{ + Architecture = 'arm64' + InstallerUrl = $Object1.assets.Where({ $_.name.EndsWith('.exe') -and $_.name.Contains('ARM64') }, '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 (zh-CN) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'zh-CN' + Key = 'ReleaseNotes' + Value = $Object1.body | Convert-MarkdownToHtml -Extensions 'advanced', 'emojis', 'hardlinebreak' | Get-TextContent | Format-Text + } + } else { + $this.Log("No ReleaseNotes (zh-CN) for version $($this.CurrentState.Version)", 'Warning') + } + + # ReleaseNotesUrl (zh-CN) + $this.CurrentState.Locale += [ordered]@{ + Locale = 'zh-CN' + Key = 'ReleaseNotesUrl' + Value = $Object1.html_url + } + } catch { + $_ | Out-Host + $this.Log($_, 'Warning') + } + + $this.Print() + $this.Write() + } + 'Changed|Updated' { + $this.Message() + } + 'Updated' { + $this.Submit() + } +}