Skip to content

Commit e334eb4

Browse files
ci: add workflow for updating WinGet manifest for WebSearchShortcut extension
1 parent 6f6e637 commit e334eb4

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# To use this template for a new extension:
2+
# 1. Copy this file to a new workflow file (e.g., update-winget.yml)
3+
# 2. Update Environmental variables with your data:
4+
# - GITHUB_REPO with your GitHub repo name
5+
# - GITHUB_REPO with your github user name (e.g., chatasweetie)
6+
# - EXTENSION_NAME with your extension name (e.g., CmdPalMyExtension)
7+
# - YOUR_PACKAGE_IDENTITY_NAME_HERE with the AppxPackageIdentityName located in the <ExtensionName>.csproj
8+
9+
10+
name: Update WinGet - WebSearchShortcut Extension
11+
12+
on:
13+
release:
14+
types: [published]
15+
workflow_dispatch:
16+
inputs:
17+
version:
18+
description: 'Version number (e.g., 0.0.2.0)'
19+
required: false
20+
type: string
21+
release_tag:
22+
description: 'Release tag (e.g., EXTENSION_NAME-v0.0.2.0)'
23+
required: false
24+
type: string
25+
26+
# Global constants: UPDATE THESE, example; EXTENSION_NAME: ${{ vars.EXTENSION_NAME || 'CmdPalMyExtension' }}
27+
env:
28+
EXTENSION_NAME: WebSearchShortcut
29+
GITHUB_USER_NAME: Daydreamer-riri
30+
GITHUB_REPO: CmdPal-WebSearchShortcut
31+
YOUR_PACKAGE_IDENTITY_NAME_HERE: Riri.WebSearchShortcut
32+
33+
jobs:
34+
update-winget:
35+
# Only run if this is a matching extension release
36+
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.name, '${{ env.EXTENSION_NAME }} Extension')
37+
runs-on: windows-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Get release info
43+
id: release
44+
run: |
45+
if ("${{ github.event_name }}" -eq "workflow_dispatch" -and "${{ inputs.version }}" -ne "") {
46+
# Use provided inputs for manual trigger
47+
echo "VERSION=${{ inputs.version }}" >> $env:GITHUB_OUTPUT
48+
echo "TAG=${{ inputs.release_tag }}" >> $env:GITHUB_OUTPUT
49+
} elseif ("${{ github.event_name }}" -eq "release") {
50+
# Extract from release event
51+
$version = "${{ github.event.release.tag_name }}" -replace "${{ env.EXTENSION_NAME }}-v", ""
52+
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
53+
echo "TAG=${{ github.event.release.tag_name }}" >> $env:GITHUB_OUTPUT
54+
} else {
55+
# Get latest release
56+
$latestRelease = gh release list --limit 1 --json tagName,name | ConvertFrom-Json | Where-Object { $_.name -like "${{ env.EXTENSION_NAME }} Extension*" }
57+
$version = $latestRelease.tagName -replace "${{ env.EXTENSION_NAME }}-v", ""
58+
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
59+
echo "TAG=$($latestRelease.tagName)" >> $env:GITHUB_OUTPUT
60+
}
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Install wingetcreate
65+
run: |
66+
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
67+
68+
- name: Update WinGet manifest
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
$version = "${{ steps.release.outputs.VERSION }}"
73+
$tag = "${{ steps.release.outputs.TAG }}"
74+
75+
# URLs for both installers
76+
$x64Url = "https://github.com/${{ env.GITHUB_USER_NAME }}/${{ env.GITHUB_REPO }}/releases/download/$tag/${{ env.EXTENSION_NAME }}-Setup-$version-x64.exe"
77+
$arm64Url = "https://github.com/${{ env.GITHUB_USER_NAME }}/${{ env.GITHUB_REPO }}/releases/download/$tag/${{ env.EXTENSION_NAME }}-Setup-$version-arm64.exe"
78+
79+
Write-Host "Updating WinGet manifest for version $version"
80+
Write-Host "x64 URL: $x64Url"
81+
Write-Host "ARM64 URL: $arm64Url"
82+
83+
# Update the manifest with both architecture installers
84+
.\wingetcreate.exe update ${{ env.YOUR_PACKAGE_IDENTITY_NAME_HERE }} `
85+
--version $version `
86+
--urls "$x64Url|x64" "$arm64Url|arm64" `
87+
--token $env:GITHUB_TOKEN `
88+
--submit

0 commit comments

Comments
 (0)