Skip to content

Commit 6be47fe

Browse files
authored
Merge pull request #1542 from QwenLM/vscode-ide-companion-github-action-publish
Add VSCode IDE Companion Release Workflow
2 parents 29e71a5 + bfe451b commit 6be47fe

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: 'Release VSCode IDE Companion'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'The version to release (e.g., v0.1.11). Required for manual patch releases.'
8+
required: false
9+
type: 'string'
10+
ref:
11+
description: 'The branch or ref (full git sha) to release from.'
12+
required: true
13+
type: 'string'
14+
default: 'main'
15+
dry_run:
16+
description: 'Run a dry-run of the release process; no branches, vsix packages or GitHub releases will be created.'
17+
required: true
18+
type: 'boolean'
19+
default: true
20+
create_preview_release:
21+
description: 'Auto apply the preview release tag, input version is ignored.'
22+
required: false
23+
type: 'boolean'
24+
default: false
25+
force_skip_tests:
26+
description: 'Select to skip the "Run Tests" step in testing. Prod releases should run tests'
27+
required: false
28+
type: 'boolean'
29+
default: false
30+
31+
concurrency:
32+
group: '${{ github.workflow }}'
33+
cancel-in-progress: false
34+
35+
jobs:
36+
release-vscode-companion:
37+
runs-on: 'ubuntu-latest'
38+
environment:
39+
name: 'production-release'
40+
url: '${{ github.server_url }}/${{ github.repository }}/releases/tag/vscode-companion-${{ steps.version.outputs.RELEASE_TAG }}'
41+
if: |-
42+
${{ github.repository == 'QwenLM/qwen-code' }}
43+
permissions:
44+
contents: 'read'
45+
issues: 'write'
46+
47+
steps:
48+
- name: 'Checkout'
49+
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
50+
with:
51+
ref: '${{ github.event.inputs.ref || github.sha }}'
52+
fetch-depth: 0
53+
54+
- name: 'Set booleans for simplified logic'
55+
env:
56+
CREATE_PREVIEW_RELEASE: '${{ github.event.inputs.create_preview_release }}'
57+
DRY_RUN_INPUT: '${{ github.event.inputs.dry_run }}'
58+
id: 'vars'
59+
run: |-
60+
is_preview="false"
61+
if [[ "${CREATE_PREVIEW_RELEASE}" == "true" ]]; then
62+
is_preview="true"
63+
fi
64+
echo "is_preview=${is_preview}" >> "${GITHUB_OUTPUT}"
65+
66+
is_dry_run="false"
67+
if [[ "${DRY_RUN_INPUT}" == "true" ]]; then
68+
is_dry_run="true"
69+
fi
70+
echo "is_dry_run=${is_dry_run}" >> "${GITHUB_OUTPUT}"
71+
72+
- name: 'Setup Node.js'
73+
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
74+
with:
75+
node-version-file: '.nvmrc'
76+
cache: 'npm'
77+
cache-dependency-path: 'package-lock.json'
78+
79+
- name: 'Install Dependencies'
80+
env:
81+
NPM_CONFIG_PREFER_OFFLINE: 'true'
82+
run: |-
83+
npm ci
84+
85+
- name: 'Install VSCE and OVSX'
86+
run: |-
87+
npm install -g @vscode/vsce
88+
npm install -g ovsx
89+
90+
- name: 'Get the version'
91+
id: 'version'
92+
working-directory: 'packages/vscode-ide-companion'
93+
run: |
94+
# Get the base version from package.json regardless of scenario
95+
BASE_VERSION=$(node -p "require('./package.json').version")
96+
97+
if [[ "${IS_PREVIEW}" == "true" ]]; then
98+
# Generate preview version with timestamp based on actual package version
99+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
100+
PREVIEW_VERSION="${BASE_VERSION}-preview.${TIMESTAMP}"
101+
RELEASE_TAG="preview.${TIMESTAMP}"
102+
103+
echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
104+
echo "RELEASE_VERSION=${PREVIEW_VERSION}" >> "$GITHUB_OUTPUT"
105+
echo "VSCODE_TAG=preview" >> "$GITHUB_OUTPUT"
106+
else
107+
# Use specified version or get from package.json
108+
if [[ -n "${MANUAL_VERSION}" ]]; then
109+
RELEASE_VERSION="${MANUAL_VERSION#v}" # Remove 'v' prefix if present
110+
RELEASE_TAG="${MANUAL_VERSION#v}" # Remove 'v' prefix if present
111+
else
112+
RELEASE_VERSION="${BASE_VERSION}"
113+
RELEASE_TAG="${BASE_VERSION}"
114+
fi
115+
116+
echo "RELEASE_TAG=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
117+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
118+
echo "VSCODE_TAG=latest" >> "$GITHUB_OUTPUT"
119+
fi
120+
env:
121+
IS_PREVIEW: '${{ steps.vars.outputs.is_preview }}'
122+
MANUAL_VERSION: '${{ inputs.version }}'
123+
124+
- name: 'Update package version (for preview releases)'
125+
if: '${{ steps.vars.outputs.is_preview == ''true'' }}'
126+
working-directory: 'packages/vscode-ide-companion'
127+
env:
128+
RELEASE_VERSION: '${{ steps.version.outputs.RELEASE_VERSION }}'
129+
run: |-
130+
# Update package.json with preview version
131+
npm version "${RELEASE_VERSION}" --no-git-tag-version --allow-same-version
132+
133+
- name: 'Run Tests'
134+
if: |-
135+
${{ github.event.inputs.force_skip_tests != 'true' }}
136+
working-directory: 'packages/vscode-ide-companion'
137+
run: |
138+
npm run test:ci
139+
env:
140+
OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}'
141+
OPENAI_BASE_URL: '${{ secrets.OPENAI_BASE_URL }}'
142+
OPENAI_MODEL: '${{ secrets.OPENAI_MODEL }}'
143+
144+
- name: 'Prepare VSCode Extension'
145+
run: |
146+
# Build and stage the extension + bundled CLI once.
147+
npm --workspace=qwen-code-vscode-ide-companion run prepackage
148+
149+
- name: 'Package VSIX (dry run)'
150+
if: '${{ steps.vars.outputs.is_dry_run == ''true'' }}'
151+
working-directory: 'packages/vscode-ide-companion'
152+
run: |-
153+
if [[ "${{ steps.vars.outputs.is_preview }}" == "true" ]]; then
154+
vsce package --pre-release --out ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix
155+
else
156+
vsce package --out ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix
157+
fi
158+
159+
- name: 'Upload VSIX Artifact (dry run)'
160+
if: '${{ steps.vars.outputs.is_dry_run == ''true'' }}'
161+
uses: 'actions/upload-artifact@v4'
162+
with:
163+
name: 'qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix'
164+
path: 'packages/qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix'
165+
if-no-files-found: 'error'
166+
167+
- name: 'Publish to Microsoft Marketplace'
168+
if: '${{ steps.vars.outputs.is_dry_run == ''false'' }}'
169+
working-directory: 'packages/vscode-ide-companion'
170+
env:
171+
VSCE_PAT: '${{ secrets.VSCE_PAT }}'
172+
VSCODE_TAG: '${{ steps.version.outputs.VSCODE_TAG }}'
173+
run: |-
174+
if [[ "${{ steps.vars.outputs.is_preview }}" == "true" ]]; then
175+
echo "Skipping Microsoft Marketplace for preview release"
176+
else
177+
vsce publish --pat "${VSCE_PAT}" --tag "${VSCODE_TAG}"
178+
fi
179+
180+
- name: 'Publish to OpenVSX'
181+
if: '${{ steps.vars.outputs.is_dry_run == ''false'' }}'
182+
working-directory: 'packages/vscode-ide-companion'
183+
env:
184+
OVSX_TOKEN: '${{ secrets.OVSX_TOKEN }}'
185+
VSCODE_TAG: '${{ steps.version.outputs.VSCODE_TAG }}'
186+
run: |-
187+
if [[ "${{ steps.vars.outputs.is_preview }}" == "true" ]]; then
188+
# For preview releases, publish with preview tag
189+
# First package the extension for preview
190+
vsce package --pre-release --out ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix
191+
ovsx publish ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix --pat "${OVSX_TOKEN}" --pre-release
192+
else
193+
# Package and publish normally
194+
vsce package --out ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix
195+
ovsx publish ../qwen-code-vscode-companion-${{ steps.version.outputs.RELEASE_VERSION }}.vsix --pat "${OVSX_TOKEN}" --tag "${VSCODE_TAG}"
196+
fi
197+
198+
- name: 'Create Issue on Failure'
199+
if: |-
200+
${{ failure() }}
201+
env:
202+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
203+
DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
204+
run: |-
205+
gh issue create \
206+
--title "VSCode IDE Companion Release Failed for ${{ steps.version.outputs.RELEASE_VERSION }} on $(date +'%Y-%m-%d')" \
207+
--body "The VSCode IDE Companion release workflow failed. See the full run for details: ${DETAILS_URL}"

0 commit comments

Comments
 (0)