Skip to content

Commit

Permalink
Adding winget workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Lessley Dennington authored and dscho committed Feb 10, 2025
1 parent 7592c76 commit 7e56c23
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release-winget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "release-winget"
on:
release:
types: [released]

workflow_dispatch:
inputs:
release:
description: 'Release Id'
required: true
default: 'latest'

permissions:
id-token: write # required for Azure login via OIDC

jobs:
release:
runs-on: windows-latest
environment: release
steps:
- name: Log into Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Publish manifest with winget-create
run: |
# Get correct release asset
$github = Get-Content '${{ github.event_path }}' | ConvertFrom-Json
$asset = $github.release.assets | Where-Object -Property name -match '64-bit.exe$'
# Remove 'v' and 'vfs' from the version
$github.release.tag_name -match '\d.*'
$version = $Matches[0] -replace ".vfs",""
# Download wingetcreate and create manifests
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update Microsoft.Git -u $asset.browser_download_url -v $version -o manifests
# Manually substitute the name of the default branch in the License
# and Copyright URLs since the tooling cannot do that for us.
$shortenedVersion = $version -replace ".{4}$"
$manifestPath = dir -Path ./manifests -Filter Microsoft.Git.locale.en-US.yaml -Recurse | %{$_.FullName}
sed -i "s/vfs-[.0-9]*/vfs-$shortenedVersion/g" "$manifestPath"
# Submit manifests
$manifestDirectory = Split-Path "$manifestPath"
.\wingetcreate.exe submit -t "(az keyvault secret show --name ${{ secrets.WINGET_TOKEN_SECRET_NAME }} --vault-name ${{ secrets.AZURE_VAULT }} --query "value")" $manifestDirectory
shell: powershell

0 comments on commit 7e56c23

Please sign in to comment.