test action
This commit is contained in:
@@ -38,22 +38,19 @@ jobs:
|
|||||||
- name: Restore NuGet Packages
|
- name: Restore NuGet Packages
|
||||||
run: nuget restore "Ink Canvas.sln"
|
run: nuget restore "Ink Canvas.sln"
|
||||||
|
|
||||||
- name: Get current version
|
- name: Get current version from Git tag
|
||||||
id: get_version
|
id: get_version
|
||||||
run: |
|
run: |
|
||||||
$versionLine = Get-Content "Ink Canvas\Properties\AssemblyInfo.cs" | Select-String "AssemblyVersion\(""([^""]+)""\)"
|
# 获取最新的tag
|
||||||
if ($versionLine) {
|
$latestTag = git describe --tags --abbrev=0 2>$null
|
||||||
$version = $versionLine.Matches[0].Groups[1].Value
|
if ($latestTag) {
|
||||||
# 处理通配符版本号
|
# 移除v前缀(如果有的话)
|
||||||
if ($version -match "(\d+)\.(\d+)\.(\*|\d+)\.(\*|\d+)") {
|
$version = $latestTag -replace "^v", ""
|
||||||
$major = $matches[1]
|
echo "Found latest tag: $latestTag"
|
||||||
$minor = $matches[2]
|
|
||||||
$patch = if ($matches[3] -eq "*") { "0" } else { $matches[3] }
|
|
||||||
$revision = if ($matches[4] -eq "*") { "0" } else { $matches[4] }
|
|
||||||
$version = "$major.$minor.$patch.$revision"
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$version = "1.0.0.0"
|
# 如果没有tag,使用默认版本
|
||||||
|
$version = "1.0.0"
|
||||||
|
echo "No tags found, using default version"
|
||||||
}
|
}
|
||||||
echo "current_version=$version" >> $env:GITHUB_OUTPUT
|
echo "current_version=$version" >> $env:GITHUB_OUTPUT
|
||||||
echo "Current version: $version"
|
echo "Current version: $version"
|
||||||
@@ -64,12 +61,13 @@ jobs:
|
|||||||
$currentVersion = "${{ steps.get_version.outputs.current_version }}"
|
$currentVersion = "${{ steps.get_version.outputs.current_version }}"
|
||||||
$versionParts = $currentVersion.Split('.')
|
$versionParts = $currentVersion.Split('.')
|
||||||
|
|
||||||
# 确保版本号格式正确
|
# 确保版本号格式正确(至少3部分)
|
||||||
if ($versionParts.Length -ge 3) {
|
if ($versionParts.Length -ge 3) {
|
||||||
$major = [int]$versionParts[0]
|
$major = [int]$versionParts[0]
|
||||||
$minor = [int]$versionParts[1]
|
$minor = [int]$versionParts[1]
|
||||||
$patch = [int]$versionParts[2]
|
$patch = [int]$versionParts[2]
|
||||||
} else {
|
} else {
|
||||||
|
# 如果版本号格式不正确,使用默认值
|
||||||
$major = 1
|
$major = 1
|
||||||
$minor = 0
|
$minor = 0
|
||||||
$patch = 0
|
$patch = 0
|
||||||
@@ -92,7 +90,8 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newVersion = "$major.$minor.$patch.0"
|
# 生成新版本号(保持3位格式,如1.7.13)
|
||||||
|
$newVersion = "$major.$minor.$patch"
|
||||||
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
|
echo "new_version=$newVersion" >> $env:GITHUB_OUTPUT
|
||||||
echo "New version: $newVersion"
|
echo "New version: $newVersion"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user