Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## WinGet Publish Workflow

- Pull Request: <https://github.com/microsoft/winget-pkgs/pull/126347> for the WinGet repository

- Workflow Source: <https://github.com/The-Running-Dev/Winget-Updates/blob/main/.github/workflows/sidequest.easyinstaller.internal.yml>

- Workflow Results: <https://github.com/The-Running-Dev/Winget-Updates/actions/runs/6864444163/job/18666214326>

What this workflow does:

1. Runs every time there is a new release pushed
2. Gets the published version from WinGet
3. Gets the latest published version from the current repository
4. If the latest version is different than the WinGet version, submits an update to the WinGet repository

## HowTo Setup

1. Generate a new personal access token at <https://github.com/settings/personal-access-tokens/new>, and give it 'Public Repositories' access, and copy it.
2. Create a new repository secret at <https://github.com/SideQuestVR/EasyInstallerReleases/settings/secrets/actions>, with the name ```PublicAccessToken```
3. The workflow will run when a new release is published
57 changes: 57 additions & 0 deletions .github/workflows/sidequest.easyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: SideQuest.EasyInstaller.Internal

on:
release:
types: [published]

jobs:
publish-to-winget:
runs-on: windows-latest
steps:
- name: Install WinGet
uses: Cyberboss/install-winget@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Install WinGetCreate
run: winget install wingetcreate --disable-interactivity --accept-source-agreements

- name: Get Latest Release
shell: pwsh
run: |
$packageId = 'SideQuestVR.SideQuestEasyInstaller'
$installerRegEx = 'SideQuest-Setup-.*-x64-win.exe$'

# Install needed modules
Install-Module Microsoft.WinGet.Client -Force

# Get the current WinGet version of the package
$winGetVersion = Find-WinGetPackage -Id $packageId | `
Select-Object -ExpandProperty version

# Get the latest release from the current repository
$release = Get-Content '${{github.event_path}}' | ConvertFrom-Json | Select-Object -ExpandProperty release
$latestVersion = $release.tag_name -replace 'v', ''

# WinGet version does not exist...
if (-not $winGetVersion) {
Write-Warning "Package Does Not Exist on WinGet...Exiting"
return
}

# Latest version and WinGet version are the same...
if ($latestVersion -eq $winGetVersion) {
Write-Warning "Latest Version ($latestVersion) == WinGet Version ($winGetVersion)...Exiting"
return
}

$downloadUrl = $release.assets | `
Where-Object -Property name -match $installerRegEx | `
Select -ExpandProperty browser_download_url

# Call WinGetCreate to update the version and URL of the package
& wingetcreate update $packageId `
--urls '$downloadUrl' '$downloadUrl' `
--version $latestVersion `
--submit `
--token '${{secrets.PublicAccessToken}}'