feat(workflow): 支持手动触发 release 和 docker 工作流

- 在 docker.yml 中添加 workflow_dispatch 触发器
- 在 release.yml 中添加 workflow_dispatch 触发器及版本输入参数
- 修改 PowerShell 脚本以支持从 Git 标签或手动输入获取版本号
- 修改 shell 脚本以支持从 Git 标签或手动输入获取版本号
- 在 test.yml 中添加 workflow_dispatch 触发器
- 添加版本号提取逻辑,兼容 Git 标签和手动输入两种方式- 添加日志输出以区分版本号来源(Git 标签或手动输入)
This commit is contained in:
linshen committed 2025-10-09 23:31:08 +08:00
1 parent 1c69a352b2
commit 05eb294cbe
3 files changed
+46 -11

No files matched your search

+1
View File
@@ -6,6 +6,7 @@ on:
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
env:
# Docker Hub 配置
+44 -11
View File
@@ -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"
+1
View File
@@ -11,6 +11,7 @@ on:
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
jobs:
test: