From 05eb294cbe93899ce4b1f01a307fba74ac7cb146 Mon Sep 17 00:00:00 2001 From: linshen <32978552+linshenkx@users.noreply.github.com> Date: Thu, 9 Oct 2025 23:31:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(workflow):=20=E6=94=AF=E6=8C=81=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E8=A7=A6=E5=8F=91=20release=20=E5=92=8C=20docker=20?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=20-=20=E5=9C=A8=20docker.yml=20?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=20workflow=5Fdispatch=20=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E5=99=A8=20-=20=E5=9C=A8=20release.yml=20=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20workflow=5Fdispatch=20=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E5=99=A8=E5=8F=8A=E7=89=88=E6=9C=AC=E8=BE=93=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20-=20=E4=BF=AE=E6=94=B9=20PowerShell=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E4=BB=A5=E6=94=AF=E6=8C=81=E4=BB=8E=20Git=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=88=96=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=89=88=E6=9C=AC=E5=8F=B7=20-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20shell=20=E8=84=9A=E6=9C=AC=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BB=8E=20Git=20=E6=A0=87=E7=AD=BE=E6=88=96=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E8=8E=B7=E5=8F=96=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=20-=20=E5=9C=A8=20test.yml=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=20wor?= =?UTF-8?q?kflow=5Fdispatch=20=E8=A7=A6=E5=8F=91=E5=99=A8=20-=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7=E6=8F=90=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=85=BC=E5=AE=B9=20Git=20=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=92=8C=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5=E4=B8=A4=E7=A7=8D?= =?UTF-8?q?=E6=96=B9=E5=BC=8F-=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E4=BB=A5=E5=8C=BA=E5=88=86=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E6=9D=A5=E6=BA=90=EF=BC=88Git=20=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=88=96=E6=89=8B=E5=8A=A8=E8=BE=93=E5=85=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 1 + .github/workflows/release.yml | 55 ++++++++++++++++++++++++++++------- .github/workflows/test.yml | 1 + 3 files changed, 46 insertions(+), 11 deletions(-) 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: