Skip to content

Publish to WinGet

Publish to WinGet #17

Workflow file for this run

name: Publish to WinGet
on:
workflow_dispatch:
jobs:
publish-winget:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '18.14.0'
- name: Install wingetcreate
run: |
winget install `
--id Microsoft.WingetCreate `
--source winget `
--accept-package-agreements `
--accept-source-agreements `
--silent
- name: Read version from winget manifest
id: manifest_version
shell: pwsh
run: |
$content = Get-Content "build/winget/manifest.yml"
$line = $content | Where-Object { $_ -match '^PackageVersion:\s*(.+)$' }
if (-not $line) { throw "PackageVersion not found in manifest" }
$version = $line -replace '^PackageVersion:\s*', ''
$version = $version.Trim()
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Compute SHA256 for the latest release
id: hash
shell: pwsh
run: |
$version = "${{ steps.manifest_version.outputs.version }}"
$url = "https://github.com/${{ github.repository }}/releases/download/v$version/Owlet-$version-win-x64.exe"
Write-Host "Downloading: $url"
Invoke-WebRequest -Uri $url -OutFile installer.exe
$hash = (Get-FileHash -Path installer.exe -Algorithm SHA256).Hash
"sha256=$hash" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"url=$url" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Update winget manifest
shell: pwsh
run: |
$path = "build/winget/manifest.yml"
$url = "${{ steps.hash.outputs.url }}"
$hash = "${{ steps.hash.outputs.sha256 }}"
$content = Get-Content $path
$content = $content -replace '(?m)^(\s*InstallerUrl:\s*).+$', "`$1$url"
$content = $content -replace '(?m)^(\s*InstallerSha256:\s*).+$', "`$1$hash"
Set-Content -Path $path -Value $content
- name: Validate manifest
shell: pwsh
run: |
winget validate `
--manifest "build/winget/manifest.yml"
- name: Submit manifest
shell: pwsh
run: |
wingetcreate submit `
--token "${{ secrets.WINGET_TOKEN }}" `
build/winget/manifest.yml