Add powershell script to download latest release

## What this change does:
Adds a power-shell script to get the latest release from GitHub and download it if the user does not have it on their disk.

## How to get this working:
Create the following directory structure:
```
---- ventoy
    ---- ventoy-update-windows.ps1
    ---- ventoy-1.0.19-windows.zip
    ---- ventoy-1.0.18-windows.zip
```
When running the script from that directory, it will check the latest downloaded release on disk and compare it with the latest release on GitHub. If a newer version exists, it will download that version in the same directory.

## Future scope of this change:
- Could be added to automate updates within app.
- This approach also allows to get the change-log using `$release.body`.
This commit is contained in:
Tanmay Pachpande 2020-08-23 21:47:22 +05:30 committed by GitHub
parent 1bf3e73373
commit 44dbbb4251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

28
ventoy-update-windows.ps1 Normal file
View File

@ -0,0 +1,28 @@
# Get the releases from GitHub
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/ventoy/Ventoy/releases"
# Iterate through the releases
forEach ($release in $releases) {
# Exclude pre-releases
if (!$release.prerelease) {
# Get the version of the release
$version = $release.tag_name
# Iterate through the release assets
forEach ($asset in $release.assets) {
# Include only Windows assets
if ($asset.name -like "*-windows.zip") {
# Download only if file does not exist on disk
if (Test-Path $asset.name) {
Write-Host "You already have the latest version of Ventoy."
break
}
else {
Invoke-WebRequest -UseBasicParsing -Uri $asset.browser_download_url -OutFile $asset.name
Write-Host "Downloaded Ventoy for Windows $version."
break
}
}
}
break
}
}