WinGet push #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WinGet push | |
on: | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@main | |
- name: Preparation | |
run: | | |
# Get local uploaded manifest version of the package | |
#$String = Get-Content -Path "Scripts\WinGet_Manifests\TeamSophia.SophiaScript.yaml" | Where-Object -FilterScript {$_ -match "ManifestVersion"} | |
#$LocalManifest = $String -split " " | Select-Object -Last 1 | |
# Get latest supported manifest version provided | |
# https://github.com/microsoft/winget-cli/tree/master/schemas/JSON/manifests | |
# https://github.com/microsoft/winget-cli/tree/master/schemas/JSON/manifests/latest | |
$Parameters = @{ | |
Uri = "https://raw.githubusercontent.com/microsoft/winget-cli/refs/heads/master/schemas/JSON/manifests/latest/manifest.version.latest.json" | |
UseBasicParsing = $true | |
Verbose = $true | |
} | |
#$LatestManifest = ((Invoke-RestMethod @Parameters).properties | Where-Object -FilterScript {$_.ManifestVersion.description -eq "The manifest syntax version"}).ManifestVersion.default | |
if ([System.Version]$LocalManifest -lt [System.Version]$LatestManifest) | |
{ | |
#Write-Warning -Message "New $($LatestManifest) manifest available. Edit manifests in Scripts\WinGet_Manifests" | |
#exit | |
} | |
# Get latest version tag for Windows 11 | |
$Parameters = @{ | |
Uri = "https://raw.githubusercontent.com/farag2/Sophia-Script-for-Windows/refs/heads/master/sophia_script_versions.json" | |
UseBasicParsing = $true | |
} | |
$Version = (Invoke-RestMethod @Parameters).Sophia_Script_Windows_11_PowerShell_5_1 | |
# Get archive hash | |
$Parameters = @{ | |
Uri = "https://github.com/farag2/Sophia-Script-for-Windows/releases/download/$($Version)/Sophia.Script.for.Windows.11.v$($Version).zip" | |
UseBasicParsing = $true | |
} | |
$Request = (Invoke-WebRequest @Parameters).RawContentStream | |
$Hash = (Get-FileHash -InputStream $Request).Hash | |
# Update the metadata for the files | |
Get-ChildItem -Path Scripts\WinGet_Manifests | ForEach-Object -Process { | |
(Get-Content -Path $_.FullName -Encoding UTF8 -Raw) | Foreach-Object -Process { | |
$_ -replace "SophiaScriptVersion", $Version ` | |
-replace "SophiaScriptHash", $Hash ` | |
-replace "SophiaScriptDate", $(Get-Date -Format "yyyy-MM-dd") | |
} | Set-Content -Path $_.FullName -Encoding utf8 -Force | |
} | |
- name: Publish to WinGet | |
run: | | |
# Get the latest wingetcreate | |
# https://github.com/microsoft/winget-create | |
$Parameters = @{ | |
Uri = "https://aka.ms/wingetcreate/latest" | |
OutFile = "wingetcreate.exe" | |
UseBasicParsing = $true | |
} | |
Invoke-WebRequest @Parameters | |
.\wingetcreate.exe submit --prtitle "New Version: TeamSophia.SophiaScript version $Version" --token "${{ secrets.WINGET_PAT }}" "Scripts\WinGet_Manifests" |