-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease.bat
More file actions
83 lines (69 loc) · 2.12 KB
/
Copy pathrelease.bat
File metadata and controls
83 lines (69 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@echo off
setlocal enabledelayedexpansion
:: --- 1. Extract and Clean Version ---
echo - Finding version in pyproject.toml...
:: Initialize variable to ensure it's not set from a previous run
set "raw_version="
:: Find the line with "version", ignore comments (#)
for /f "tokens=2 delims==" %%A in ('findstr /i "version" pyproject.toml ^| findstr /v "#"') do (
set "raw_version=%%~A"
)
if not defined raw_version (
echo.
echo [ERROR] Could not find a 'version =' line in pyproject.toml.
exit /b 1
)
:: Clean the extracted string: remove all quotes and spaces
set "cleaned_version=!raw_version:"=!"
set "cleaned_version=!cleaned_version: =!"
if not defined cleaned_version (
echo.
echo [ERROR] Version string is empty after cleaning. Check pyproject.toml.
exit /b 1
)
set "tag=v!cleaned_version!"
echo - Detected version: %tag%
echo.
:: --- 2. Get Commit Message ---
set /p commit_msg="Enter commit message for release %tag%: "
if not defined commit_msg (
echo - Commit message was empty. Using a default message.
set "commit_msg=Release %tag%"
)
echo.
:: --- 3. Git Operations ---
echo - Staging all changes...
git add .
echo - Committing changes...
git commit -m "%commit_msg%"
if errorlevel 1 (
echo - No changes to commit. Continuing to tag release.
)
echo - Creating/updating local tag %tag%...
:: The -f flag forces the update of the tag if it already exists
git tag -f %tag%
if errorlevel 1 (
echo.
echo [ERROR] Failed to create tag %tag%. Aborting.
exit /b 1
)
echo - Pushing main branch to origin...
git push origin main
if errorlevel 1 (
echo.
echo [ERROR] Failed to push main branch. Aborting.
exit /b 1
)
echo - Pushing tag %tag% to origin (will overwrite if it exists)...
:: The -f flag forces the update of the remote tag
git push origin %tag% -f
if errorlevel 1 (
echo.
echo [ERROR] Failed to push tag %tag%.
echo This can happen if the remote repository protects tags from being overwritten.
exit /b 1
)
echo.
echo =================================================
echo Success! Released %tag% to main.
echo =================================================