I want to take this command
To upgrade an existing GYB install, run:
bash <(curl -s -S -L https://git.io/gyb-install) -l
The -l at the end tells the download script to upgrade to latest version and not perform the project setup steps. This will preserve your current settings and existing backups.
and make it something that work in windows PowerShell.
The end goal is to make a windows script that updates to the latest release of a program called GYB https://github.com/GAM-team/got-your-back/releases automatically.
I don't have any code to offer since I don't have any good ideas to accomplish what I want.
Any help would be appreciated.
CodePudding user response:
Rather than using their bash script, just downloading the latest file with that name from github with powershell worked ok for me.
Try this one (original from https://gist.github.com/MarkTiedemann/c0adc1701f3f5c215fc2c2d5b1d5efd3)
$repo = "GAM-team/got-your-back"
$releases = "https://api.github.com/repos/$repo/releases"
Write-Host Determining latest release
$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].tag_name
$file = "gyb-$($tag.Replace('v',''))-windows-x86_64.msi" #filename happens to have tag without the v prefix, this could probably be improved by someone who knows github better
$download = "https://github.com/$repo/releases/download/$tag/$file"
Write-Host Dowloading latest release
Invoke-WebRequest $download -Out $file #saves to current path, you probably want to specify folder here
CodePudding user response:
This is what I did. Thanks to the answer above.
$repo = "GAM-team/got-your-back"
$releases = "https://api.github.com/repos/$repo/releases"
$InstalledGYB = 'v' (gyb --short-version)
Write-Host Determining latest release -ForegroundColor Yellow
$tag = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].tag_name
$CurrentRelease = "gyb-$($tag.Replace('v',''))-windows-x86_64.msi" #filename happens to have tag without the v prefix, this could probably be improved by someone who knows github better
If ($InstalledGYB -ne $Tag) {
$download = "https://github.com/$repo/releases/download/$tag/$CurrentRelease"
Write-Host Dowloading latest release -ForegroundColor Yellow
Invoke-WebRequest $download -OutFile "C:\GYB\$CurrentRelease" #saves to current path, you probably want to specify folder here
Start-Process -Filepath "C:\GYB\$CurrentRelease" -ArgumentList "/passive" -Wait | Wait-Process -Timeout 60
Remove-Item "C:\GYB\$CurrentReleasea" -Force -ErrorAction SilentlyContinue
}
Else {
Write-Host GYB Current -ForegroundColor Green
}