69 lines
2.0 KiB
Batchfile
69 lines
2.0 KiB
Batchfile
@echo off
|
||
setlocal enabledelayedexpansion
|
||
|
||
:: 设置Git仓库URL
|
||
set repo_url=http://chenyf:h992416737@chenyf123.top:1030/chenyf/fcma_qt_maco.git
|
||
set release_url=%repo_url%/releases/download
|
||
set download_file=app_data.zip
|
||
set local_tag_path=maco_qt_tag
|
||
:: app目录
|
||
set target_dir=app
|
||
|
||
:: 检查下是否有git命令
|
||
where git >nul 2>nul
|
||
if %errorlevel% neq 0 (
|
||
msg * "没有找到git命令,请安装git后再运行此脚本,请手动执行install_env.bat."
|
||
pause
|
||
exit
|
||
)
|
||
|
||
if not exist %target_dir% mkdir %target_dir%
|
||
|
||
if not exist %local_tag_path% mkdir %local_tag_path%
|
||
|
||
set latest_tag_name=
|
||
:: 获取 Git 仓库的tag 列表
|
||
git ls-remote --tags %repo_url% > %local_tag_path%\orign_tags.txt
|
||
:: 读取最新tag名称
|
||
for /f "tokens=3 delims=/" %%i in (%local_tag_path%\orign_tags.txt) do set latest_tag_name=%%i
|
||
|
||
echo latest_tag_name=%latest_tag_name%
|
||
|
||
set local_tags=
|
||
:: 检查是否有本地版本文件 local_tags.txt
|
||
if exist %local_tag_path%\local_tags.txt (
|
||
:: 读取本地版本文件中的tag信息
|
||
set /p local_tags=<%local_tag_path%\local_tags.txt
|
||
)
|
||
echo local_tags=%local_tags%
|
||
::检查是否有新版本
|
||
if "%local_tags%"=="" (
|
||
:: 没有本地版本文件,直接拉取最新的release文件
|
||
echo 没有本地版本文件,直接拉取最新的release文件
|
||
goto :func_download_app
|
||
) else (
|
||
:: 有本地版本文件,检查是否有新版本
|
||
if "%local_tags%"=="%latest_tag_name%" (
|
||
echo 本地版本已是最新版本
|
||
goto :func_end
|
||
) else (
|
||
echo 有新版本,准备下载
|
||
goto :func_clean_local_app
|
||
)
|
||
)
|
||
|
||
:func_clean_local_app
|
||
del /s /q %target_dir%
|
||
:func_download_app
|
||
echo download_url=%release_url%/%latest_tag_name%/%download_file%
|
||
curl -o %target_dir%\%download_file% -L %release_url%/%latest_tag_name%/%download_file%
|
||
:: 解压文件到app目录
|
||
powershell -Command "Expand-Archive -Path %target_dir%/%download_file% -DestinationPath %target_dir%"
|
||
::删除下载的zip文件
|
||
del %target_dir%\%download_file%
|
||
:: 更新本地版本文件
|
||
echo %latest_tag_name%>%local_tag_path%\local_tags.txt
|
||
goto :func_end
|
||
|
||
:func_end
|
||
@REM pause |