feat: 更新 Web 项目发布构建的 GitHub Action,确保版本号输出统一添加 v 前缀,优化版本获取逻辑,更新文档以反映新格式和使用示例。

This commit is contained in:
Lyda
2025-08-20 19:29:45 +08:00
parent da4e1db20d
commit e4063690cd
5 changed files with 53 additions and 45 deletions

View File

@@ -28,7 +28,7 @@ jobs:
- name: 发布(自定义版本文件)
uses: actions/xgj/release-web@main
with:
release-command: "echo '1.2.3' > ./custom-version.txt"
release-command: "echo 'v1.2.3' > ./custom-version.txt"
version-file: "./custom-version.txt"
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
@@ -63,7 +63,7 @@ jobs:
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git commit --allow-empty -m "release: 1.2.6"
git commit --allow-empty -m "release: v1.2.6"
- name: 发布(基于提交信息)
uses: actions/xgj/release-web@main

View File

@@ -37,13 +37,13 @@ jobs:
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- name: 验证版本输出(应包含 v
- name: 验证版本输出(应包含 v 前缀
run: |
echo "版本输出: ${{ steps.test1.outputs.version }}"
if [[ "${{ steps.test1.outputs.version }}" == "1.2.3" ]]; then
echo "✅ 正确:版本文件 v 前缀已去除"
if [[ "${{ steps.test1.outputs.version }}" == "v1.2.3" ]]; then
echo "✅ 正确:版本文件 v 前缀保持不变"
else
echo "❌ 错误:版本应该是 1.2.3,实际是 ${{ steps.test1.outputs.version }}"
echo "❌ 错误:版本应该是 v1.2.3,实际是 ${{ steps.test1.outputs.version }}"
exit 1
fi
@@ -67,10 +67,10 @@ jobs:
- name: 验证 git tag 版本输出
run: |
echo "Git tag 版本输出: ${{ steps.test2.outputs.version }}"
if [[ "${{ steps.test2.outputs.version }}" == "1.2.4" ]]; then
echo "✅ 正确Git tag v 前缀已去除"
if [[ "${{ steps.test2.outputs.version }}" == "v1.2.4" ]]; then
echo "✅ 正确Git tag v 前缀保持不变"
else
echo "❌ 错误:版本应该是 1.2.4,实际是 ${{ steps.test2.outputs.version }}"
echo "❌ 错误:版本应该是 v1.2.4,实际是 ${{ steps.test2.outputs.version }}"
exit 1
fi
@@ -93,10 +93,10 @@ jobs:
- name: 验证 package.json 版本输出
run: |
echo "Package.json 版本输出: ${{ steps.test3.outputs.version }}"
if [[ "${{ steps.test3.outputs.version }}" == "1.2.5" ]]; then
echo "✅ 正确Package.json v 前缀已去除"
if [[ "${{ steps.test3.outputs.version }}" == "v1.2.5" ]]; then
echo "✅ 正确Package.json 版本已添加 v 前缀"
else
echo "❌ 错误:版本应该是 1.2.5,实际是 ${{ steps.test3.outputs.version }}"
echo "❌ 错误:版本应该是 v1.2.5,实际是 ${{ steps.test3.outputs.version }}"
exit 1
fi
@@ -120,10 +120,10 @@ jobs:
- name: 验证提交信息版本输出
run: |
echo "提交信息版本输出: ${{ steps.test4.outputs.version }}"
if [[ "${{ steps.test4.outputs.version }}" == "1.2.6" ]]; then
echo "✅ 正确:提交信息 v 前缀已去除"
if [[ "${{ steps.test4.outputs.version }}" == "v1.2.6" ]]; then
echo "✅ 正确:提交信息 v 前缀保持不变"
else
echo "❌ 错误:版本应该是 1.2.6,实际是 ${{ steps.test4.outputs.version }}"
echo "❌ 错误:版本应该是 v1.2.6,实际是 ${{ steps.test4.outputs.version }}"
exit 1
fi
@@ -131,18 +131,18 @@ jobs:
- name: 验证版本带横线格式
run: |
echo "版本带横线: ${{ steps.test4.outputs.version-with-dash }}"
if [[ "${{ steps.test4.outputs.version-with-dash }}" == "1-2-6" ]]; then
if [[ "${{ steps.test4.outputs.version-with-dash }}" == "v1-2-6" ]]; then
echo "✅ 正确:版本横线格式正确"
else
echo "❌ 错误:版本横线格式应该是 1-2-6实际是 ${{ steps.test4.outputs.version-with-dash }}"
echo "❌ 错误:版本横线格式应该是 v1-2-6实际是 ${{ steps.test4.outputs.version-with-dash }}"
exit 1
fi
- name: 测试总结
run: |
echo "🎉 所有版本处理测试通过!"
echo "✅ 版本文件 v 前缀处理正确"
echo "✅ Git tag v 前缀处理正确"
echo "✅ Package.json v 前缀处理正确"
echo "✅ 提交信息 v 前缀处理正确"
echo "✅ 版本横线格式正确"
echo "✅ 版本文件 v 前缀保持不变"
echo "✅ Git tag v 前缀保持不变"
echo "✅ Package.json 版本自动添加 v 前缀"
echo "✅ 提交信息 v 前缀保持不变"
echo "✅ 版本横线格式包含 v 前缀"