Skip to content

Instantly share code, notes, and snippets.

@alimbada
Last active December 12, 2024 18:43
Show Gist options
  • Save alimbada/fe6a3052632677ed00cef80b7d43b6ae to your computer and use it in GitHub Desktop.
Save alimbada/fe6a3052632677ed00cef80b7d43b6ae to your computer and use it in GitHub Desktop.
Download and install the latest release of an app from a GitHub repo
#!bin/bash
repo=$1
release=$(curl -s https://api.github.com/repos/$repo/releases/latest | jq '.assets[] | select(.name | endswith("aarch64.dmg"))')
outfile=~/Downloads/$(jq -r .name <<<$release)
curl -L $(jq -r .browser_download_url <<<$release) --output $outfile
$repo = $args[0];
$outdir = $args[1]
$release = (curl -s https://api.github.com/repos/scito/extract_otp_secrets/releases/latest | ConvertFrom-Json).assets | where { $_.name -like "*.msi" -or $_.name -like "*.exe" }
# TODO: check there's only one item
$outFile = "$outdir\$($release.name)";
curl -L $release.browser_download_url --output $outFile;
& $outFile
@alimbada
Copy link
Author

alimbada commented Sep 27, 2024

For apps that are unavailable via WinGet or Chocolatey, this script can be used to download and install the latest version of an app when it notifies you that there's an update available.

Replace value of $repo with any repo which contains Windows Installer releases, e.g. $repo = "JPersson77/LGTVCompanion"

@alimbada
Copy link
Author

Requires PowerShell 7+ as the curl command in previous PS versions is an alias of Invoke-WebRequest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment