-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdate-version.ps1
More file actions
82 lines (71 loc) · 3.2 KB
/
update-version.ps1
File metadata and controls
82 lines (71 loc) · 3.2 KB
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
# PandaCoder 版本更新脚本
# 使用方法: .\update-version.ps1
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "PandaCoder 版本更新工具" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""
# 读取 gradle.properties
$propsFile = "gradle.properties"
if (-not (Test-Path $propsFile)) {
Write-Host "错误: 未找到 gradle.properties 文件" -ForegroundColor Red
exit 1
}
$props = @{}
Get-Content $propsFile | ForEach-Object {
if ($_ -match '^\s*([^#=]+?)\s*=\s*(.+?)\s*$') {
$props[$matches[1]] = $matches[2]
}
}
$pluginVersion = $props['pluginVersion']
$versionType = $props['versionType']
$releaseDate = $props['releaseDate']
$currentFeatures = $props['currentFeatures']
Write-Host "当前版本配置:" -ForegroundColor Yellow
Write-Host " 版本号: $pluginVersion"
Write-Host " 版本类型: $versionType"
Write-Host " 发布日期: $releaseDate"
Write-Host " 主要功能: $currentFeatures"
Write-Host ""
# 1. 更新 version.properties
Write-Host "正在更新 version.properties..." -ForegroundColor Green
$versionPropsPath = "src\main\resources\version.properties"
$versionPropsContent = @"
# Auto-generated version information
# DO NOT EDIT THIS FILE MANUALLY
# This file is generated by update-version.ps1 script
# To update version, edit gradle.properties file and run: .\update-version.ps1
version=$pluginVersion
versionType=$versionType
releaseDate=$releaseDate
currentFeatures=$currentFeatures
"@
[System.IO.File]::WriteAllText((Resolve-Path $versionPropsPath).Path, $versionPropsContent, [System.Text.Encoding]::UTF8)
Write-Host " ✓ 已更新: $versionPropsPath" -ForegroundColor Green
# 2. 更新 README.md
Write-Host "正在更新 README.md..." -ForegroundColor Green
$readmePath = "README.md"
if (Test-Path $readmePath) {
$readmeContent = [System.IO.File]::ReadAllText($readmePath, [System.Text.Encoding]::UTF8)
$readmeContent = $readmeContent -replace 'https://img\.shields\.io/badge/Version-[\d.]+', "https://img.shields.io/badge/Version-$pluginVersion"
[System.IO.File]::WriteAllText((Resolve-Path $readmePath).Path, $readmeContent, [System.Text.Encoding]::UTF8)
Write-Host " ✓ 已更新: $readmePath" -ForegroundColor Green
} else {
Write-Host " ✗ 未找到: $readmePath" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "✓ 版本更新完成!" -ForegroundColor Green
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "已更新的文件:" -ForegroundColor Yellow
Write-Host " 1. src\main\resources\version.properties"
Write-Host " 2. README.md"
Write-Host ""
Write-Host "下一步操作:" -ForegroundColor Yellow
Write-Host " 1. 运行 .\gradlew clean build 重新构建项目"
Write-Host " 2. 提交更改到 Git: git add ."
Write-Host " 然后: git commit -m 'chore: update version to $pluginVersion'"
Write-Host " 3. 创建版本标签: git tag v$pluginVersion"
Write-Host " 4. 推送到远程: git push"
Write-Host " 然后: git push --tags"
Write-Host "=========================================" -ForegroundColor Cyan