diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 97a1dfca..d2352a9f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + workflow_dispatch: env: # Docker Hub 配置 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab04d4af..ec9ac1c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,12 @@ on: tags: - 'v*.*.*' # 正式版本: v1.0.0, v2.1.3 - 'v*.*.*-*' # 预览版本: v1.0.0-beta.1, v1.0.0-rc.1 + workflow_dispatch: + inputs: + version: + description: '版本号(例如: v2.0.3)' + required: true + type: string env: NODE_VERSION: '22' @@ -39,8 +45,14 @@ jobs: $pkgPath = "packages/desktop/package.json" $pkgJson = Get-Content $pkgPath -Raw | ConvertFrom-Json - # 1. 从 Git 标签提取版本号 (移除 'v' 前缀) - $tagVersion = "${{ github.ref }}".replace("refs/tags/v", "") + # 1. 从 Git 标签或手动输入提取版本号 (移除 'v' 前缀) + if ("${{ github.event_name }}" -eq "workflow_dispatch") { + $tagVersion = "${{ inputs.version }}".replace("v", "") + Write-Host "📝 Using manual input version: $tagVersion" + } else { + $tagVersion = "${{ github.ref }}".replace("refs/tags/v", "") + Write-Host "🏷️ Using git tag version: $tagVersion" + } $pkgJson.version = $tagVersion Write-Host "✅ Set version to: $tagVersion" @@ -163,10 +175,17 @@ jobs: - name: 动态配置 package.json run: | PKG_PATH="packages/desktop/package.json" - - # 1. 从 Git 标签提取版本号 (移除 'v' 前缀) - TAG_VERSION="${{ github.ref }}" - TAG_VERSION="${TAG_VERSION#refs/tags/v}" + + # 1. 从 Git 标签或手动输入提取版本号 (移除 'v' 前缀) + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + TAG_VERSION="${{ inputs.version }}" + TAG_VERSION="${TAG_VERSION#v}" + echo "📝 Using manual input version: $TAG_VERSION" + else + TAG_VERSION="${{ github.ref }}" + TAG_VERSION="${TAG_VERSION#refs/tags/v}" + echo "🏷️ Using git tag version: $TAG_VERSION" + fi echo "✅ Set version to: $TAG_VERSION" # 2. 设置仓库地址 (自动感知当前仓库) @@ -282,10 +301,17 @@ jobs: - name: 动态配置 package.json run: | PKG_PATH="packages/desktop/package.json" - - # 1. 从 Git 标签提取版本号 (移除 'v' 前缀) - TAG_VERSION="${{ github.ref }}" - TAG_VERSION="${TAG_VERSION#refs/tags/v}" + + # 1. 从 Git 标签或手动输入提取版本号 (移除 'v' 前缀) + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + TAG_VERSION="${{ inputs.version }}" + TAG_VERSION="${TAG_VERSION#v}" + echo "📝 Using manual input version: $TAG_VERSION" + else + TAG_VERSION="${{ github.ref }}" + TAG_VERSION="${TAG_VERSION#refs/tags/v}" + echo "🏷️ Using git tag version: $TAG_VERSION" + fi echo "✅ Set version to: $TAG_VERSION" # 2. 设置仓库地址 (自动感知当前仓库) @@ -392,7 +418,14 @@ jobs: - name: 获取版本号和类型 id: version run: | - VERSION=${GITHUB_REF#refs/tags/} + # 从 Git 标签或手动输入获取版本号 + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + VERSION="${{ inputs.version }}" + echo "📝 Using manual input version: $VERSION" + else + VERSION=${GITHUB_REF#refs/tags/} + echo "🏷️ Using git tag version: $VERSION" + fi echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Version: $VERSION" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 740fed10..43b38584 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,7 @@ on: paths-ignore: - '**.md' - 'docs/**' + workflow_dispatch: jobs: test: