forked from Moonfin-Client/Moonfin-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2.84 KB
/
Copy pathwinget.yml
File metadata and controls
69 lines (59 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: WinGet submission on release
on:
workflow_dispatch:
inputs:
tag:
description: Release tag to publish (defaults to the latest release)
required: false
release:
types: [published]
jobs:
winget:
name: Publish winget package
# wingetcreate is only supported on Windows
runs-on: windows-latest
# wingetcreate reads the GitHub token it submits the PR with from here.
# See https://aka.ms/winget-create-token
env:
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_ACC_TOKEN }}
# Only submit stable releases. On a manual run there is no release payload,
# so this passes and the tag input decides what gets published.
if: ${{ !github.event.release.prerelease }}
steps:
- name: Submit Moonfin.Moonfin to the Windows Package Manager Community Repository
shell: pwsh
run: |
$tag = '${{ inputs.tag }}'
if (-not $tag) { $tag = '${{ github.event.release.tag_name }}' }
# Read the assets back from the API rather than the event payload:
# the release event can fire before the installers finish uploading,
# and this also gives the manual path a way in.
$api = 'https://api.github.com/repos/${{ github.repository }}/releases'
$url = if ($tag) { "$api/tags/$tag" } else { "$api/latest" }
foreach ($attempt in 1..6) {
$release = Invoke-RestMethod -Uri $url -Headers @{
Authorization = 'Bearer ${{ github.token }}'
}
$x64 = $release.assets | Where-Object name -match '^Moonfin_Windows_v.*\.exe$' |
Select-Object -ExpandProperty browser_download_url
$arm64 = $release.assets | Where-Object name -match '^Moonfin_WindowsARM64_v.*\.exe$' |
Select-Object -ExpandProperty browser_download_url
if ($x64 -and $arm64) { break }
Write-Host "Installers not uploaded yet ($attempt/6), waiting"
Start-Sleep -Seconds 30
}
if (-not ($x64 -and $arm64)) {
throw "Release $($release.tag_name) is missing a Windows installer"
}
$packageVersion = $release.tag_name.TrimStart('v')
Write-Host "Submitting Moonfin.Moonfin $packageVersion"
# Both installers are passed because the merged manifest carries an
# x64 and an arm64 entry; sending one would drop the other. The
# architecture is pinned rather than inferred - the x64 file name has
# nothing in it for wingetcreate to infer from.
curl.exe -JLO https://aka.ms/wingetcreate/latest
.\wingetcreate.exe update Moonfin.Moonfin `
--version $packageVersion `
--urls "$x64|x64" "$arm64|arm64" `
--release-notes-url "https://github.com/${{ github.repository }}/releases/tag/$($release.tag_name)" `
--submit