-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Glarysoft.GlaryUtilities automation
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: .github/workflows/Gitbutler.GitButler.yml PR | ||
# based off of https://github.com/nushell/nushell/blob/main/.github/workflows/winget-submission.yml | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: 3 0/4 * * * | ||
env: | ||
PackageName: .github/workflows/Gitbutler.GitButler.yml | ||
|
||
jobs: | ||
winget: | ||
name: Publish winget package | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
path: Utesgui | ||
- name: Install winget | ||
uses: Cyberboss/install-winget@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Update package | ||
id: get_version | ||
working-directory: Utesgui | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.WINGET_PAT }} | ||
WINGET_PKGS_FORK_REPO: ${{ vars.WINGET_PKGS_FORK_REPO }} | ||
run: .\Scripts\Update-${{ env.PackageName }}.ps1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
if ($Env:GITHUB_TOKEN) { | ||
Write-Host 'GITHUB_TOKEN detected' | ||
$gitToken = ${Env:GITHUB_TOKEN} | ||
} | ||
else { | ||
Write-Host 'GITHUB_TOKEN not detected' | ||
exit 1 | ||
} | ||
|
||
$wingetPackage = "Glarysoft.GlaryUtilities" | ||
|
||
|
||
# download latest version from loupedeck.com and get version by filename | ||
$latestVersionUrl = "https://download.glarysoft.com/gusetup.exe" | ||
#create directory downloads and change into it | ||
$DownloadFileName = "gusetup.exe" | ||
Invoke-WebRequest -Uri $latestVersionUrl -OutFile $DownloadFileName | ||
$file = Get-ChildItem -Path $DownloadFileName | ||
$versionInfo = $file.VersionInfo.ProductVersionRaw | ||
|
||
if ($null -eq $versionInfo) { | ||
Write-Host "Could not find version info in file" | ||
exit 1 | ||
} | ||
|
||
Write-Host "Found latest version: $versionInfo" | ||
|
||
$latestVersion = $versionInfo | ||
|
||
$fullDownloadURL = $latestVersionUrl | ||
|
||
$prMessage = "Update version: $wingetPackage version $latestVersion" | ||
|
||
$foundMessage, $textVersion, $separator, $wingetVersions = winget search --id $wingetPackage --source winget --versions | ||
|
||
# Check for existing versions in winget | ||
if ($wingetVersions -contains $latestVersion) { | ||
Write-Output "Latest version of $wingetPackage $latestVersion is already present in winget." | ||
exit 0 | ||
} | ||
else { | ||
# Check for existing PRs | ||
$ExistingPRs = gh pr list --search "$($wingetPackage) version $($latestVersion) in:title draft:false" --state 'all' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json | ||
|
||
# TODO Check if PR is already merged, if so exit | ||
|
||
# TODO if PR from us is already open, update PR with new version | ||
|
||
# TODO if PR is closed, not from us and no PR got merged, create new PR | ||
|
||
# TODO if PR is closed, from us and no PR got merged, throw error | ||
|
||
if ($ExistingPRs.Count -gt 0) { | ||
Write-Output "$foundMessage" | ||
$ExistingPRs | ForEach-Object { | ||
Write-Output "Found existing PR: $($_.title)" | ||
Write-Output "-> $($_.url)" | ||
} | ||
} | ||
elseif ($wingetVersions -and ($wingetVersions -notmatch $latestVersion)) { | ||
Write-Output "Downloading wingetcreate and open PR for $wingetPackage Version $latestVersion" | ||
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe | ||
.\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken | ||
} | ||
else { | ||
Write-Output "$foundMessage" | ||
Write-Output "No existing PRs found. Check why wingetcreate has not run." | ||
} | ||
} |