@echo off setlocal EnableExtensions set "TAG=%~1" if "%TAG%"=="" goto list set "MESSAGE=%~2" if "%MESSAGE%"=="" set "MESSAGE=Release %TAG%" where git >nul 2>nul if errorlevel 1 ( echo Git not found in PATH. exit /b 1 ) git rev-parse --is-inside-work-tree >nul 2>nul if errorlevel 1 ( echo Not a git repository. exit /b 1 ) git check-ref-format "refs/tags/%TAG%" >nul 2>nul if errorlevel 1 ( echo Invalid tag name: %TAG% exit /b 1 ) git rev-parse -q --verify "refs/tags/%TAG%" >nul 2>nul if not errorlevel 1 ( echo Tag already exists: %TAG% exit /b 1 ) for /f "delims=" %%i in ('git status --porcelain') do ( echo Working tree is not clean: echo %%i exit /b 1 ) echo Repository: %CD% echo Tag: %TAG% echo Message: %MESSAGE% echo Commit: git log -1 --oneline echo. set /p ANSWER=Create this tag? [y/N] if /i not "%ANSWER%"=="y" ( echo Cancelled. exit /b 0 ) git tag -a "%TAG%" -m "%MESSAGE%" if errorlevel 1 ( echo Failed to create tag. exit /b 1 ) echo. git show --stat --oneline "%TAG%" echo. echo Tag created. Push it with: echo git push origin "%TAG%" exit /b 0 :list where git >nul 2>nul if errorlevel 1 ( echo Git not found in PATH. exit /b 1 ) git rev-parse --is-inside-work-tree >nul 2>nul if errorlevel 1 ( echo Not a git repository. exit /b 1 ) echo Tags sorted by version: git tag --sort=-v:refname exit /b 0