Files
Commercialization.topon/Update Upm.bat

96 lines
2.1 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
:: Set UTF-8 encoding
chcp 65001
:: Set window title
title UPM Package Update Tool
:: Set console color
color a
echo 开始提交到git upm....
echo 提交upm前请确保当前分支所有改动都已经提交
:: Extract version from package.json
for /f "tokens=2 delims=:, " %%i in ('findstr "version" Assets\package.json') do (
set version=%%i
)
:: Remove quotes
set version=%version:"=%
echo 从package.json中读取的版本号为%version%
:: Check if tag exists
git tag | findstr "%version%" > nul
if %errorlevel% equ 0 (
echo 错误:版本号 %version% 对应的tag已存在
pause
exit
)
set /p Flg=确认提交的版本号%version%,是否开始提交(y/n) -------- :
IF "%Flg%" equ "y" (
echo 开始提交,请勿关闭该窗口!
:: Force switch to master first
git checkout -f master
:: Delete local upm branch if exists
git branch -D upm 2>nul
:: Create new upm branch from current Assets folder
git subtree split --prefix=Assets --branch upm
if %errorlevel% neq 0 (
echo 错误创建upm分支失败
goto :END
)
:: Force update local upm branch with remote changes
git fetch origin upm
git checkout -f upm
git reset --hard origin/upm
:: Create new subtree split
git checkout -f master
git subtree split --prefix=Assets --branch upm-temp
:: Apply new changes and force push
git checkout -f upm
git merge upm-temp --allow-unrelated-histories -X theirs
git branch -D upm-temp
:: Create and push tag with explicit steps
echo 创建并推送tag %version%...
git tag -d %version% 2>nul
git tag %version% upm
if %errorlevel% neq 0 (
echo 错误创建tag失败
git checkout -f master
goto :END
)
:: Push changes and tags separately
echo 推送upm分支...
git push -f origin upm
if %errorlevel% neq 0 (
echo 错误推送upm分支失败
git checkout -f master
goto :END
)
echo 推送tag...
git push origin %version%
if %errorlevel% neq 0 (
echo 错误推送tag失败
git tag -d %version%
git checkout -f master
goto :END
)
:: Return to master branch
git checkout -f master
)
:END
echo 执行完成!
pause
exit