Last active
April 22, 2023 10:51
-
-
Save Alistair1231/3ec2c6baa7d822518617e29aabe34cad to your computer and use it in GitHub Desktop.
get latest github release using curl on bash (ex. revanced-cli)
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
# ######## | |
# # bash # | |
# ######## | |
# pattern="ATLauncher-.*" | |
# repo="Alistair1231/ATLauncher-Offline" | |
# # remove old files | |
# rm -f description.txt && rm -f ATLauncher-*.jar | |
# # get the files | |
# curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -oP '"browser_download_url":\s*"\K[^"]+' | grep -E "$pattern" | wget -q --show-progress -i - | |
# # get the description | |
# curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -oP '"body":\s*"\K[^"]+' | sed -e 's/\\r\\n/\n/g' -e 's/\\n/\n/g' -e 's/^[[:space:]]+//' | tr -d '```' > description.txt | |
############## | |
# powershell # | |
############## | |
$pattern="ATLauncher-.*" | |
$repo="Alistair1231/ATLauncher-Offline" | |
# remove old files | |
if (Test-Path $pattern) { rm -Force $pattern } | |
if (Test-Path "description.txt") { rm -Force "description.txt" } | |
# get the files | |
(Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest").assets.browser_download_url | | |
Select-String -Pattern $pattern | | |
ForEach-Object { | |
Invoke-WebRequest $($_ | Select-Object -ExpandProperty line) -OutFile $($_.Matches.Value.Split("/")[-1]) | |
} | |
# get the description | |
Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest" | | |
Select-Object -ExpandProperty body | | |
ForEach-Object {$_ -replace '\\r\\n', "`n" -replace '^[[:space:]]+', '' -replace '```', ''} | | |
Set-Content -Path "description.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment