@echo off
cd /d %~dp0
::读取版本配置文件
set configVersion=version.txt
for /f "tokens=1,2,3 delims=." %%a IN (%configVersion%)  Do (
     set tag1=%%a
     set tag2=%%b
     set tag3=%%c
)
set oldVersion=%tag1%.%tag2%.%tag3%
echo v%oldVersion%

::提交数据，并打包为节点
cd /d %rootPath%
set tagName=%oldVersion%_%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
git tag -a %tagName% -m 建立节点
git push origin %tagName%

pause

::切换到根目录
cd ..
set rootPath=%cd%

::打包数据库脚本
set oldversionDB=%rootPath%\2.database\v%oldVersion%
if not exist %oldversionDB% (
    md %oldversionDB%
)

copy /y  %rootPath%\2.database\数据库脚本.txt %oldversionDB%\
copy /y  %rootPath%\2.database\v*.txt %oldversionDB%\
del /q %rootPath%\2.database\v*.txt

::写入版本
::set /a tag3=%tag3%+1
echo oldVersion = v%tag1%.%tag2%.%tag3%
set newVersion=%tag1%.%tag2%.%tag3%

echo %tag1%.%tag2%.%tag3%>%configVersion%
echo newVersion = v%newVersion%

del /q %rootPath%\v*.txt
type nul>v%newVersion%.txt
type nul>%rootPath%\2.database\v%newVersion%.txt
type nul>%rootPath%\2.database\数据库脚本.txt


pause