forked from QwenLM/qwen-code
-
Notifications
You must be signed in to change notification settings - Fork 0
359 lines (324 loc) · 12.8 KB
/
release-vscode-companion.yml
File metadata and controls
359 lines (324 loc) · 12.8 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
name: 'Release VSCode IDE Companion'
on:
workflow_dispatch:
inputs:
version:
description: 'The version to release (e.g., v0.1.11). Required for manual patch releases.'
required: false
type: 'string'
ref:
description: 'The branch or ref (full git sha) to release from.'
required: true
type: 'string'
default: 'main'
dry_run:
description: 'Run a dry-run of the release process; no branches, vsix packages or GitHub releases will be created.'
required: true
type: 'boolean'
default: true
create_preview_release:
description: 'Create a preview release. If version includes -preview.<id>, it is used as-is; otherwise a timestamp is appended.'
required: false
type: 'boolean'
default: false
force_skip_tests:
description: 'Select to skip the "Run Tests" step in testing. Prod releases should run tests'
required: false
type: 'boolean'
default: false
concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: false
jobs:
# First job: Determine version and run tests once
prepare:
runs-on: 'ubuntu-latest'
if: |-
${{ github.repository == 'QwenLM/qwen-code' }}
permissions:
contents: 'read'
outputs:
release_version: '${{ steps.version.outputs.RELEASE_VERSION }}'
release_tag: '${{ steps.version.outputs.RELEASE_TAG }}'
vscode_tag: '${{ steps.version.outputs.VSCODE_TAG }}'
is_preview: '${{ steps.vars.outputs.is_preview }}'
is_dry_run: '${{ steps.vars.outputs.is_dry_run }}'
steps:
- name: 'Checkout'
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
ref: '${{ github.event.inputs.ref || github.sha }}'
fetch-depth: 0
- name: 'Set booleans for simplified logic'
env:
CREATE_PREVIEW_RELEASE: '${{ github.event.inputs.create_preview_release }}'
DRY_RUN_INPUT: '${{ github.event.inputs.dry_run }}'
id: 'vars'
run: |-
is_preview="false"
if [[ "${CREATE_PREVIEW_RELEASE}" == "true" ]]; then
is_preview="true"
fi
echo "is_preview=${is_preview}" >> "${GITHUB_OUTPUT}"
is_dry_run="false"
if [[ "${DRY_RUN_INPUT}" == "true" ]]; then
is_dry_run="true"
fi
echo "is_dry_run=${is_dry_run}" >> "${GITHUB_OUTPUT}"
- name: 'Setup Node.js'
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: 'Install Dependencies'
env:
NPM_CONFIG_PREFER_OFFLINE: 'true'
run: |-
npm ci
- name: 'Get the version'
id: 'version'
working-directory: 'packages/vscode-ide-companion'
run: |
# Get the base version from package.json regardless of scenario
BASE_VERSION=$(node -p "require('./package.json').version")
if [[ "${IS_PREVIEW}" == "true" ]]; then
# Generate preview version. If a manual version is provided and already
# contains -preview.<id>, use it as-is (no timestamp). Otherwise, append
# a timestamp for uniqueness.
if [[ -n "${MANUAL_VERSION}" ]]; then
MANUAL_CLEAN="${MANUAL_VERSION#v}" # Remove 'v' prefix if present
if [[ "${MANUAL_CLEAN}" == *"-preview."* ]]; then
PREVIEW_VERSION="${MANUAL_CLEAN}"
else
PREVIEW_BASE="${MANUAL_CLEAN%%-*}" # Strip any prerelease/build
TIMESTAMP=$(date +%Y%m%d%H%M%S)
PREVIEW_VERSION="${PREVIEW_BASE}-preview.${TIMESTAMP}"
fi
else
TIMESTAMP=$(date +%Y%m%d%H%M%S)
PREVIEW_VERSION="${BASE_VERSION}-preview.${TIMESTAMP}"
fi
RELEASE_TAG="${PREVIEW_VERSION}"
echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
echo "RELEASE_VERSION=${PREVIEW_VERSION}" >> "$GITHUB_OUTPUT"
echo "VSCODE_TAG=preview" >> "$GITHUB_OUTPUT"
else
# Use specified version or get from package.json
if [[ -n "${MANUAL_VERSION}" ]]; then
RELEASE_VERSION="${MANUAL_VERSION#v}" # Remove 'v' prefix if present
RELEASE_TAG="${MANUAL_VERSION#v}" # Remove 'v' prefix if present
else
RELEASE_VERSION="${BASE_VERSION}"
RELEASE_TAG="${BASE_VERSION}"
fi
echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
echo "VSCODE_TAG=latest" >> "$GITHUB_OUTPUT"
fi
env:
IS_PREVIEW: '${{ steps.vars.outputs.is_preview }}'
MANUAL_VERSION: '${{ inputs.version }}'
- name: 'Build webui dependency'
if: |-
${{ github.event.inputs.force_skip_tests != 'true' }}
run: |
npm run build --workspace=@qwen-code/webui
- name: 'Run Tests'
if: |-
${{ github.event.inputs.force_skip_tests != 'true' }}
working-directory: 'packages/vscode-ide-companion'
run: |
npm run test:ci
env:
OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}'
OPENAI_BASE_URL: '${{ secrets.OPENAI_BASE_URL }}'
OPENAI_MODEL: '${{ secrets.OPENAI_MODEL }}'
# Second job: Build platform-specific VSIXes in parallel
build:
needs: 'prepare'
strategy:
fail-fast: false
matrix:
include:
# Platform-specific builds (with node-pty native binaries)
- os: 'ubuntu-latest'
target: 'linux-x64'
universal: false
# macOS 15 (x64): use macos-15-intel
# Endpoint Badge: macos-latest-large, macos-15-large, or macos-15-intel
- os: 'macos-15-intel'
target: 'darwin-x64'
universal: false
# macOS 15 Arm64: use macos-latest
# Endpoint Badge: macos-latest, macos-15, or macos-15-xlarge
- os: 'macos-latest'
target: 'darwin-arm64'
universal: false
- os: 'windows-latest'
target: 'win32-x64'
universal: false
# Universal fallback (without node-pty, uses child_process)
- os: 'ubuntu-latest'
target: ''
universal: true
runs-on: '${{ matrix.os }}'
permissions:
contents: 'read'
steps:
- name: 'Checkout'
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
ref: '${{ github.event.inputs.ref || github.sha }}'
fetch-depth: 0
- name: 'Setup Node.js'
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: 'Install Dependencies'
env:
NPM_CONFIG_PREFER_OFFLINE: 'true'
run: |-
npm ci
- name: 'Install VSCE'
run: |-
npm install -g @vscode/vsce
- name: 'Update package version'
env:
RELEASE_VERSION: '${{ needs.prepare.outputs.release_version }}'
shell: 'bash'
run: |-
npm run release:version -- "${RELEASE_VERSION}"
- name: 'Prepare VSCode Extension'
env:
UNIVERSAL_BUILD: '${{ matrix.universal }}'
VSCODE_TARGET: '${{ matrix.target }}'
run: |
# Build and stage the extension + bundled CLI
npm --workspace=qwen-code-vscode-ide-companion run prepackage
- name: 'Package VSIX (platform-specific)'
if: '${{ matrix.target != '''' }}'
working-directory: 'packages/vscode-ide-companion'
run: |-
if [[ "${{ needs.prepare.outputs.is_preview }}" == "true" ]]; then
vsce package --no-dependencies --pre-release --target ${{ matrix.target }} \
--out ../../qwen-code-vscode-companion-${{ needs.prepare.outputs.release_version }}-${{ matrix.target }}.vsix
else
vsce package --no-dependencies --target ${{ matrix.target }} \
--out ../../qwen-code-vscode-companion-${{ needs.prepare.outputs.release_version }}-${{ matrix.target }}.vsix
fi
shell: 'bash'
- name: 'Package VSIX (universal)'
if: '${{ matrix.target == '''' }}'
working-directory: 'packages/vscode-ide-companion'
run: |-
if [[ "${{ needs.prepare.outputs.is_preview }}" == "true" ]]; then
vsce package --no-dependencies --pre-release \
--out ../../qwen-code-vscode-companion-${{ needs.prepare.outputs.release_version }}-universal.vsix
else
vsce package --no-dependencies \
--out ../../qwen-code-vscode-companion-${{ needs.prepare.outputs.release_version }}-universal.vsix
fi
shell: 'bash'
- name: 'Upload VSIX Artifact'
uses: 'actions/upload-artifact@v4'
with:
name: 'vsix-${{ matrix.target || ''universal'' }}'
path: 'qwen-code-vscode-companion-${{ needs.prepare.outputs.release_version }}-*.vsix'
if-no-files-found: 'error'
# Third job: Publish all VSIXes to marketplaces
publish:
needs:
- 'prepare'
- 'build'
runs-on: 'ubuntu-latest'
environment:
name: 'production-release'
url: '${{ github.server_url }}/${{ github.repository }}/releases/tag/vscode-companion-${{ needs.prepare.outputs.release_tag }}'
permissions:
contents: 'read'
issues: 'write'
steps:
- name: 'Checkout'
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
with:
ref: '${{ github.event.inputs.ref || github.sha }}'
- name: 'Download all VSIX artifacts'
uses: 'actions/download-artifact@v4'
with:
pattern: 'vsix-*'
path: 'vsix-artifacts'
merge-multiple: true
- name: 'List downloaded artifacts'
run: |-
echo "Downloaded VSIX files:"
ls -la vsix-artifacts/
- name: 'Install VSCE and OVSX'
run: |-
npm install -g @vscode/vsce
npm install -g ovsx
- name: 'Publish to Microsoft Marketplace'
if: '${{ needs.prepare.outputs.is_dry_run == ''false'' && needs.prepare.outputs.is_preview != ''true'' }}'
env:
VSCE_PAT: '${{ secrets.VSCE_PAT }}'
run: |-
echo "Publishing to Microsoft Marketplace..."
for vsix in vsix-artifacts/*.vsix; do
echo "Publishing: ${vsix}"
vsce publish --packagePath "${vsix}" --pat "${VSCE_PAT}" --skip-duplicate
done
- name: 'Publish to OpenVSX'
if: '${{ needs.prepare.outputs.is_dry_run == ''false'' }}'
env:
OVSX_TOKEN: '${{ secrets.OVSX_TOKEN }}'
run: |-
echo "Publishing to OpenVSX..."
for vsix in vsix-artifacts/*.vsix; do
echo "Publishing: ${vsix}"
if [[ "${{ needs.prepare.outputs.is_preview }}" == "true" ]]; then
ovsx publish "${vsix}" --pat "${OVSX_TOKEN}" --pre-release
else
ovsx publish "${vsix}" --pat "${OVSX_TOKEN}"
fi
done
- name: 'Upload all VSIXes as release artifacts (dry run)'
if: '${{ needs.prepare.outputs.is_dry_run == ''true'' }}'
uses: 'actions/upload-artifact@v4'
with:
name: 'all-vsix-packages-${{ needs.prepare.outputs.release_version }}'
path: 'vsix-artifacts/*.vsix'
if-no-files-found: 'error'
report-failure:
name: 'Create Issue on Failure'
needs:
- 'prepare'
- 'build'
- 'publish'
if: |-
${{
always() &&
(
needs.build.result == 'failure' ||
needs.build.result == 'cancelled' ||
needs.publish.result == 'failure' ||
needs.publish.result == 'cancelled'
)
}}
runs-on: 'ubuntu-latest'
permissions:
contents: 'read'
issues: 'write'
steps:
- name: 'Create failure issue'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
RELEASE_VERSION: '${{ needs.prepare.outputs.release_version }}'
DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
GH_REPO: '${{ github.repository }}'
run: |-
gh issue create \
--repo "${GH_REPO}" \
--title "VSCode IDE Companion Release Failed for ${RELEASE_VERSION} on $(date +'%Y-%m-%d')" \
--body "The VSCode IDE Companion release workflow failed. See the full run for details: ${DETAILS_URL}"