Skip to content

Commit 50300ea

Browse files
committed
修正部署脚本, 改进版本生成脚本
1 parent 0eb0d59 commit 50300ea

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

.github/workflows/pre-release.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Pre-release Build
33
# 触发条件配置
44
on:
55
push:
6-
76
branches-ignore:
87
- "master" # 明确忽略 master,由 release.yml 处理
98

@@ -21,6 +20,7 @@ jobs:
2120
steps:
2221
- uses: actions/checkout@v6
2322
with:
23+
ref: ${{ github.ref }} # 明确 checkout 触发 workflow 的分支
2424
# 获取所有历史记录,为了确保能获取到 git tags
2525
fetch-depth: 0 # Required to fetch tags
2626

@@ -35,7 +35,12 @@ jobs:
3535
- name: Check Version
3636
id: check_version
3737
run: |
38+
echo "=== Debug: Git Status ==="
3839
echo "Current Ref: ${{ github.ref }}"
40+
echo "Current SHA: ${{ github.sha }}"
41+
git branch -v
42+
git log -1 --oneline
43+
echo "========================="
3944
BRANCH_NAME=${{ github.ref_name }}
4045
echo "Triggered by branch: $BRANCH_NAME. Checking against master..."
4146
@@ -71,6 +76,13 @@ jobs:
7176
id: build
7277
if: steps.check_version.outputs.should_release == 'true'
7378
run: |
79+
echo "=== Debug: Build Environment ==="
80+
git branch -v
81+
git log -1 --oneline
82+
echo "manifest.json version:"
83+
jq -r .version manifest.json
84+
echo "================================"
85+
7486
pnpm install
7587
pnpm run build
7688
mkdir ${{ env.NAME }}
@@ -100,6 +112,7 @@ jobs:
100112
name: "${{ steps.check_version.outputs.release_tag }}-alpha"
101113
draft: false
102114
prerelease: true
115+
target_commitish: ${{ github.sha }} # 明确指定在当前分支的 commit 上创建 tag
103116
files: |
104117
${{ env.NAME }}-v${{ steps.check_version.outputs.release_tag }}.zip
105118
main.js

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v6
2222
with:
23+
ref: ${{ github.ref }} # 明确 checkout 触发 workflow 的分支
2324
# 获取所有历史记录,为了确保能获取到 git tags
2425
fetch-depth: 0 # Required to fetch tags
2526

update-version.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/**
33
* 用法(在项目根目录):
44
* pnpm run ver -- 0.7.0 # 将 version 设置为 0.7.0
5-
* pnpm run ver -- patch # 将 patch 自增(如 0.6.24 -> 0.6.25)
5+
* pnpm run ver -- patch (或 c) # 将 patch 自增(如 0.6.24 -> 0.6.25)
6+
* pnpm run ver -- minor (或 b) # 将 minor 自增(如 0.6.24 -> 0.6.25)
7+
* pnpm run ver -- major (或 a) # 将 major 自增(如 0.6.24 -> 0.6.25)
68
* 或者使用环境变量: NEW_VERSION=0.7.0 pnpm run ver
79
*
810
* 优先级(目标版本来源):
@@ -58,8 +60,12 @@ function updateFileVersion(filePath, targetVersion, bumpOption) {
5860
// 主逻辑
5961
(function main() {
6062
const rawArgs = process.argv.slice(2); // 通过 npm run bump -- <args> 传入
61-
const arg = rawArgs[0];
62-
const envVersion = process.env.NEW_VERSION || process.env.npm_package_version || null;
63+
64+
const aliasMap = { 'a': 'major', 'b': 'minor', 'c': 'patch' };
65+
const resolve = (v) => aliasMap[v] || v;
66+
67+
const arg = resolve(rawArgs[0]);
68+
const envVersion = resolve(process.env.NEW_VERSION || process.env.npm_package_version || null);
6369
const bumpOptions = new Set(['major', 'minor', 'patch']);
6470

6571
let newVersion = null;

0 commit comments

Comments
 (0)