-
Notifications
You must be signed in to change notification settings - Fork 10
/
release.bat
148 lines (123 loc) · 3.88 KB
/
release.bat
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@echo off
setlocal enabledelayedexpansion
rem Set variables
set ARG=%*
set SHELL_DIR=%~dp0
set SHELL_DIR=%SHELL_DIR:"=%
set TEMP_DIR=%SHELL_DIR%\temp_release
set TEMP_PYTHON_DIR=%TEMP_DIR%\cubrid-python
set GIT_PATH=C:\Program Files\Git\bin\git.exe
set FIRST_VERSION_FILE=%TEMP_PYTHON_DIR%\VERSION
set SECOND_VERSION_FILE=%SHELL_DIR%\VERSION
set MAJOR_START_DATE=2017-06-27
set PYTHON_EXECUTE_END=6
set PYTHON_EXECUTE[0]=C:\python\python26\python.exe
set PYTHON_EXECUTE[1]=C:\python\python27\python.exe
set PYTHON_EXECUTE[2]=C:\python\python30\python.exe
set PYTHON_EXECUTE[3]=C:\python\python31\python.exe
set PYTHON_EXECUTE[4]=C:\python\python32\python.exe
set PYTHON_EXECUTE[5]=C:\python\python36\python.exe
set /a PYTHON_COUNT=0
set BUILD_FOLDERS=lib.win-amd64-2.6 lib.win-amd64-2.7 lib.win-amd64-3.0 lib.win-amd64-3.1 lib.win-amd64-3.2 lib.win-amd64-3.6
:main
echo %TEMP_PYTHON_DIR%
if not "%ARG%"=="" (
if "%ARG%"=="-h" (
call :show_usage
exit /b 0
)
)
if not exist "%GIT_PATH%" (
echo [ERROR] Git not found
exit /b 1
)
rem Initialize temp directory
if exist "%TEMP_DIR%" (
rmdir /s /q "%TEMP_DIR%"
)
mkdir "%TEMP_DIR%"
cd /d "%TEMP_DIR%"
echo "source download"
"%GIT_PATH%" clone git@github.com:hwany7seo/cubrid-python.git -b new_windows_release_test --recursive
echo "Handle commit ID if provided"
if not "%ARG%"=="" (
echo [CHECK] input commit id: %ARG%
cd /D "%TEMP_PYTHON_DIR%"
"%GIT_PATH%" reset --HARD %ARG%
"%GIT_PATH%" submodule update
)
if exist "%FIRST_VERSION_FILE%" (
echo [CHECK] 1st version file: %FIRST_VERSION_FILE%
for /f "usebackq tokens=*" %%a in ("%FIRST_VERSION_FILE%") do set VERSION=%%a
) else if exist "%SECOND_VERSION_FILE%" (
echo [CHECK] 2nd version file: %SECOND_VERSION_FILE%
for /f "usebackq tokens=*" %%a in (%SECOND_VERSION_FILE%) do set VERSION=%%a
) else (
echo [ERROR] Version file not found
exit /b 1
)
:build_env
echo "Execute ENV Batch For Windows"
call "%SHELL_DIR%\env_windows.bat"
:build
rem Driver Build
echo "Driver Build"
cd /d "%TEMP_DIR%\cubrid-python"
if %PYTHON_COUNT% lss %PYTHON_EXECUTE_END% (
echo "BUILD %%PYTHON_EXECUTE[%PYTHON_COUNT%]%%"
call "%%PYTHON_EXECUTE[%PYTHON_COUNT%]%%" setup.py build
set /a PYTHON_COUNT+=1
goto build
)
:zip
echo Python Driver Version is %VERSION%
set FOLDER_NAME=RB-%VERSION%
cd /d "%TEMP_PYTHON_DIR%"
for /f "delims=" %%a in ('"%GIT_PATH%" rev-list --count --after=%MAJOR_START_DATE% HEAD') do (
set SERIAL_NUMBER=%%a
)
set SERIAL_NUMBER=0000%SERIAL_NUMBER%
set SERIAL_NUMBER=%SERIAL_NUMBER:~-4%
set DRIVER_VERSION=%VERSION%.%SERIAL_NUMBER%
REM Compress and move files
echo "%TEMP_PYTHON_DIR%\build"
cd /d "%TEMP_PYTHON_DIR%\build"
ls
for %%F in (%BUILD_FOLDERS%) do (
echo Processing %%F
set "PYTHON_VERSION=%%F"
if not exist "%FOLDER_NAME%" (
echo "create dir %FOLDER_NAME%"
mkdir "%FOLDER_NAME%"
ls
) else (
echo "exist dir"
rmdir /s /q "%FOLDER_NAME%"
mkdir "%FOLDER_NAME%"
)
xcopy "%%F\*" "%FOLDER_NAME%" /E /I /H /C /Y
set "PYTHON_VERSION=!PYTHON_VERSION:~-3,3!"
set "PYTHON_VERSION=!PYTHON_VERSION:.=!"
echo "!PYTHON_VERSION!"
echo "%DRIVER_VERSION%"
powershell -Command Compress-Archive -Path "%FOLDER_NAME%" -DestinationPath "CUBRID-!DRIVER_VERSION!-windows-python!PYTHON_VERSION!-amd64.zip"
rmdir /s /q "%FOLDER_NAME%"
)
echo SERIAL_NUMBER: %SERIAL_NUMBER%
echo VERSION %VERSION%.%SERIAL_NUMBER% Completed
exit /b 0
:show_usage
echo Usage: %0 [OPTIONS or Commit-ID]
echo Note. For Python Driver Release
echo.
echo OPTIONS
echo -? ^| -h Show this help message and exit
echo.
echo Commit-ID
echo Command) git reset --hard [Commit-ID]
echo git submodule update
echo.
echo EXAMPLES
echo %0 # Compress
echo %0 a6ae44b76dc283bd74c555fef1585ed0ec7dc470 # Git Reset, Submodule Update and Compress
exit /b 1