From 59141b0241e98f1a19010b2188f5f2e13afbbc85 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Fri, 3 Oct 2025 11:04:00 +0800 Subject: [PATCH] test action --- .github/workflows/prerelease.yml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index d9263ea7..2ddcc17a 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -46,7 +46,20 @@ jobs: - name: Get current version id: get_version run: | - $version = (Get-Content "Ink Canvas\Properties\AssemblyInfo.cs" | Select-String "AssemblyVersion\(""([^""]+)""\)").Matches[0].Groups[1].Value + $versionLine = Get-Content "Ink Canvas\Properties\AssemblyInfo.cs" | Select-String "AssemblyVersion\(""([^""]+)""\)" + if ($versionLine) { + $version = $versionLine.Matches[0].Groups[1].Value + # 处理通配符版本号 + if ($version -match "(\d+)\.(\d+)\.(\*|\d+)\.(\*|\d+)") { + $major = $matches[1] + $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 { + $version = "1.0.0.0" + } echo "current_version=$version" >> $env:GITHUB_OUTPUT echo "Current version: $version" @@ -55,9 +68,17 @@ jobs: run: | $currentVersion = "${{ steps.get_version.outputs.current_version }}" $versionParts = $currentVersion.Split('.') - $major = [int]$versionParts[0] - $minor = [int]$versionParts[1] - $patch = [int]$versionParts[2] + + # 确保版本号格式正确 + if ($versionParts.Length -ge 3) { + $major = [int]$versionParts[0] + $minor = [int]$versionParts[1] + $patch = [int]$versionParts[2] + } else { + $major = 1 + $minor = 0 + $patch = 0 + } $versionType = "${{ github.event.inputs.version_type }}"