Skip to content

Commit

Permalink
update gitbutler
Browse files Browse the repository at this point in the history
  • Loading branch information
Utesgui authored Apr 29, 2024
1 parent ecc35a0 commit f276a0f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ else {

$wingetPackage = "Gitbutler.GitButler"

Write-Host "Try to update $wingetPackage"

# Follow redirect of https://app.gitbutler.com/downloads/release/windows/x86_64/msi
$website = "https://app.gitbutler.com/downloads/release/windows/x86_64/msi"
$absolutURL=[System.Net.HttpWebRequest]::Create($website).GetResponse().ResponseUri.AbsoluteUri
Expand All @@ -17,6 +19,7 @@ $absolutURL=[System.Net.HttpWebRequest]::Create($website).GetResponse().Response
$regex = "^(http|https)://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$"
if ($absolutURL -match $regex) {
$latestVersionUrl = $absolutURL
Write-Host "URL is valid"
}
else {
Write-Host "URL is not valid"
Expand All @@ -30,6 +33,7 @@ $fileName = $latestVersionUrl.Split("/")[-1]
# Get Version via Regex. The version is the part betweet "GitButler_" and "_x64"
$latestVersion = $fileName -replace ".*GitButler_(.*)_(x64|x86).*", '$1'

Write-Host "Version found: $latestVersion"

$prMessage = "Update version: $wingetPackage version $latestVersion"

Expand All @@ -41,6 +45,7 @@ if ($wingetVersions -contains $latestVersion) {
}
else {
# Check for existing PRs
Write-Host "Fetching existing PRs"
$ExistingOpenPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'open' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json
$ExistingMergedPRs = gh pr list --search "$($wingetPackage) $($latestVersion) in:title draft:false" --state 'merged' --json 'title,url' --repo 'microsoft/winget-pkgs' | ConvertFrom-Json

Expand All @@ -62,6 +67,7 @@ else {
}
}
elseif ($wingetVersions -and ($wingetVersions -notmatch $latestVersion)) {
Write-Host "Open PR for update"
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
.\wingetcreate.exe update $wingetPackage -s -v $latestVersion -u "$latestVersionUrl" --prtitle $prMessage -t $gitToken
}
Expand Down

0 comments on commit f276a0f

Please sign in to comment.