-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
118 lines (113 loc) · 3.95 KB
/
.gitlab-ci.yml
File metadata and controls
118 lines (113 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
stages:
- test-build
- release
- release-vscode
# 只在符合 cli-release-vx.x.x 或 vscode-release-vx.x.x 或 test-all-vx.x.x 的 tag 时触发
workflow:
rules:
- if: '$CI_COMMIT_TAG =~ /^cli-release-v\d+\.\d+\.\d+$/'
- if: '$CI_COMMIT_TAG =~ /^vscode-release-v\d+\.\d+\.\d+$/'
- if: '$CI_COMMIT_TAG =~ /^test-all-v\d+\.\d+\.\d+$/'
# 全局 npm 缓存配置
cache:
key:
files:
# 根据锁文件变化决定缓存重建
- package-lock.json
- packages/vscode-ui-plugin/package-lock.json
paths:
# 缓存目录:根 node_modules、子包和 npm 缓存
- node_modules/
- packages/*/node_modules/
- packages/vscode-ui-plugin/webview/node_modules/
- .npm/
policy: pull-push
test-build:
stage: test-build
tags:
- deepvcode-docker-runner
image: node:20
variables:
GIT_DEPTH: 1
script:
# 配置 npm 缓存目录(写入到项目 .npm)
- npm config set cache /cache/.npm --global
# 安装依赖(禁用 prepare 钩子,避免重复构建)
- SKIP_PREPARE=1 npm ci --retry=10 --retry-delay=5000 --prefer-offline
# 仅构建,不发布
- npm run build
rules:
- if: '$CI_COMMIT_TAG =~ /^test-all-v\d+\.\d+\.\d+$/'
release:
stage: release
tags:
- deepvcode-docker-runner # ✅ 必须匹配 config.toml 的 name 或 tag
image: node:20
variables:
GIT_DEPTH: 1
before_script:
- rm -f .npmrc || true
script:
# 配置 npm 缓存目录(写入到项目 .npm)
- npm config set cache /cache/.npm --global
# 安装依赖(禁用 prepare 钩子,避免重复构建)
- SKIP_PREPARE=1 npm ci --retry=10 --retry-delay=5000 --prefer-offline
# 提取版本号
- export NEW_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^cli-release-v//')
# 更新版本号
- npm version "$NEW_VERSION" --no-git-tag-version --force
# 发布到 npm(设置 SKIP_PREPARE=1 让 prepare 钩子也跳过)
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
- export SKIP_PREPARE=1
- npm publish
after_script:
- rm -f .npmrc || true
rules:
- if: '$CI_COMMIT_TAG =~ /^cli-release-v\d+\.\d+\.\d+$/'
release-vscode:
stage: release-vscode
tags:
- deepvcode-docker-runner # ✅ 与上保持一致
image: node:20
variables:
GIT_DEPTH: 1
script:
- npm config set cache /cache/.npm --global
- SKIP_PREPARE=1 npm ci --retry=10 --retry-delay=5000 --prefer-offline
- export NEW_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/^vscode-release-v//')
# Build core package (required dependency for vscode-ui-plugin)
- npm run build --workspace=packages/core
- cd packages/vscode-ui-plugin
- npm version "$NEW_VERSION" --no-git-tag-version --force
- npm run build:prod
# 发布到 VSCode Marketplace(版本已存在时打印警告并继续)
- |
if npx @vscode/vsce publish -p "${VSCE_TOKEN}" 2>&1 | tee /tmp/vsce_output.log; then
echo "✅ Successfully published to VSCode Marketplace"
else
if grep -q "already exists" /tmp/vsce_output.log; then
echo "⚠️ WARNING: Version already exists on VSCode Marketplace, skipping..."
else
echo "❌ Failed to publish to VSCode Marketplace"
exit 1
fi
fi
- npx @vscode/vsce package -o ../../deepv-code-vscode-"$NEW_VERSION".vsix
# 发布到 Open VSX(版本已存在时打印警告并继续)
- |
if npx ovsx publish -p "${OVSX_TOKEN}" --packagePath ../../deepv-code-vscode-"$NEW_VERSION".vsix 2>&1 | tee /tmp/ovsx_output.log; then
echo "✅ Successfully published to Open VSX"
else
if grep -q "already exists" /tmp/ovsx_output.log; then
echo "⚠️ WARNING: Version already exists on Open VSX, skipping..."
else
echo "❌ Failed to publish to Open VSX"
exit 1
fi
fi
artifacts:
paths:
- "*.vsix"
expire_in: 1 week
rules:
- if: '$CI_COMMIT_TAG =~ /^vscode-release-v\d+\.\d+\.\d+$/'