Skip to content

Commit

Permalink
update 1 file and delete 1 file
Browse files Browse the repository at this point in the history
  • Loading branch information
Maicarons committed Jun 13, 2024
1 parent 8c61567 commit 7ee561d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion RealAirplaneTag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>RealAirplaneTag</AssemblyName>
<Description>RealAirplaneTag</Description>
<Version>0.2.5</Version>
<Version>0.2.6</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
Expand Down
22 changes: 0 additions & 22 deletions tag.cmd

This file was deleted.

41 changes: 41 additions & 0 deletions tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import re
import subprocess

def find_csproj_path():
"""查找当前目录下的.csproj文件路径"""
for root, dirs, files in os.walk('.'):
for file in files:
if file.endswith('.csproj'):
return os.path.join(root, file)
return None

# 获取当前目录
current_dir = os.getcwd()

# 查找.csproj文件
csproj_path = find_csproj_path()
if csproj_path is None:
print("在当前目录及其子目录下未找到.csproj文件。")
exit(1)

# 从csproj文件中读取版本号
with open(csproj_path, 'r', encoding='utf-8') as file:
content = file.read()
match = re.search(r'<Version>([\d.]+)</Version>', content)
if match:
version = match.group(1)
else:
print("无法找到Version标签")
exit(1)

print(f"当前版本: {version}")

# 构建标签名并执行Git命令打标签并推送
tag_name = f"v{version}"
try:
subprocess.run(['git', 'tag', '-a', tag_name, '-m', f"Release {tag_name}"], check=True)
subprocess.run(['git', 'push', 'origin', '--tags'], check=True)
print(f"标签 {tag_name} 已成功创建并推送。")
except subprocess.CalledProcessError as e:
print(f"执行Git命令时发生错误: {e}")

0 comments on commit 7ee561d

Please sign in to comment.