Skip to content

Instantly share code, notes, and snippets.

@craeckor
Last active January 31, 2024 15:51
Show Gist options
  • Save craeckor/e30062a52854fbd5b3ea81471d5500a8 to your computer and use it in GitHub Desktop.
Save craeckor/e30062a52854fbd5b3ea81471d5500a8 to your computer and use it in GitHub Desktop.
Get latest release tag from a github repo
@echo off
setlocal enabledelayedexpansion
set header=-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" -H "Connection: keep-alive" -H "Pragma: no-cache" -H "Cache-Control: no-cache"
set repo=PowerShell/PowerShell
for /f "tokens=7 delims=/" %%i in ('curl -s !header! -I "https://github.com/!repo!/releases/latest" 2^>^&1 ^| findstr "Location:"') do (
set tag=%%i
)
echo !tag!
endlocal
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment