1- # VS Code Extension Release Workflow
2- # This workflow builds, tests, packages, and publishes VS Code extensions
3- # Triggers on GitHub releases and supports both stable and pre-releases
1+ # VS Code Extension Release Workflow - Fixed Version
42
53name : Release VS Code Extension
64
108 workflow_dispatch :
119 inputs :
1210 release_type :
13- description : " Release type"
11+ description : ' Release type'
1412 required : true
15- default : " patch"
13+ default : ' patch'
1614 type : choice
1715 options :
1816 - patch
1917 - minor
2018 - major
2119 - prerelease
2220 marketplace_publish :
23- description : " Publish to VS Code Marketplace"
21+ description : ' Publish to VS Code Marketplace'
2422 required : false
2523 default : true
2624 type : boolean
2725 openvsx_publish :
28- description : " Publish to Open VSX Registry"
26+ description : ' Publish to Open VSX Registry'
2927 required : false
3028 default : true
3129 type : boolean
@@ -40,56 +38,81 @@ permissions:
4038jobs :
4139 release :
4240 runs-on : ubuntu-latest
43-
41+
4442 steps :
4543 - name : Checkout repository
4644 uses : actions/checkout@v4
4745 with :
4846 fetch-depth : 0 # Fetch all history for proper versioning
49-
47+
5048 - name : Setup pnpm
5149 uses : pnpm/action-setup@v4
5250 with :
5351 version : 9
5452 run_install : false # We'll handle installation manually for better caching
55-
53+
5654 - name : Get pnpm store directory
5755 shell : bash
5856 run : |
5957 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
60-
58+
6159 - name : Setup pnpm cache
6260 uses : actions/cache@v4
6361 with :
6462 path : ${{ env.STORE_PATH }}
6563 key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
6664 restore-keys : |
6765 ${{ runner.os }}-pnpm-store-
68-
66+
6967 - name : Setup Node.js
7068 uses : actions/setup-node@v4
7169 with :
72- node-version : " 20 "
73- cache : " pnpm"
74-
70+ node-version : ' 20 '
71+ cache : ' pnpm'
72+
7573 - name : Install dependencies
7674 run : pnpm install --frozen-lockfile
77-
75+
7876 - name : Install vsce and ovsx
7977 run : |
8078 pnpm add -D @vscode/vsce
8179 pnpm add -D ovsx
82-
83- # Run tests if they exist
80+
81+ # Setup headless environment for VS Code tests
82+ - name : Setup headless environment
83+ run : |
84+ sudo apt-get update
85+ sudo apt-get install -y xvfb libasound2-dev libgtk-3-dev libnss3-dev
86+
87+ # Run tests with xvfb for headless mode
8488 - name : Run tests
8589 run : |
90+ export DISPLAY=:99.0
91+ export XDG_RUNTIME_DIR=/run/user/$(id -u)
92+ export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
93+
94+ # Start D-Bus session
95+ mkdir -p $XDG_RUNTIME_DIR
96+ dbus-daemon --session --address=$DBUS_SESSION_BUS_ADDRESS --nofork --nopidfile --syslog-only &
97+
98+ # Start Xvfb with proper configuration
99+ Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
100+
101+ # Wait for Xvfb to start
102+ sleep 3
103+
104+ # Create VS Code config to disable hardware acceleration
105+ mkdir -p ~/.vscode
106+ echo '{ "disable-hardware-acceleration": true }' > ~/.vscode/argv.json
107+
108+ # Run tests
86109 if [ -f "package.json" ] && grep -q '"test"' package.json; then
87- pnpm test
110+ xvfb-run -a --server-args="-screen 0 1024x768x24 -ac +extension GLX +render -noreset" pnpm test
88111 else
89112 echo "No tests found, skipping test step"
90113 fi
91114 continue-on-error : false
92-
115+
93116 # Build/compile if build script exists
94117 - name : Build extension
95118 run : |
@@ -100,7 +123,7 @@ jobs:
100123 else
101124 echo "No build/compile script found, skipping build step"
102125 fi
103-
126+
104127 # Package the extension
105128 - name : Package extension
106129 id : package
@@ -111,12 +134,12 @@ jobs:
111134 # Use vsce directly if no package script
112135 npx vsce package --no-dependencies
113136 fi
114-
137+
115138 # Get the generated VSIX filename
116139 VSIX_FILE=$(ls *.vsix | head -1)
117140 echo "vsix_file=$VSIX_FILE" >> $GITHUB_OUTPUT
118141 echo "Generated VSIX: $VSIX_FILE"
119-
142+
120143 # Validate the package
121144 - name : Validate package
122145 run : |
@@ -125,16 +148,16 @@ jobs:
125148 echo "ERROR: VSIX file not found: $VSIX_FILE"
126149 exit 1
127150 fi
128-
151+
129152 # Check file size (should be reasonable)
130153 FILE_SIZE=$(stat -c%s "$VSIX_FILE")
131154 if [ $FILE_SIZE -lt 1000 ]; then
132155 echo "ERROR: VSIX file seems too small: $FILE_SIZE bytes"
133156 exit 1
134157 fi
135-
158+
136159 echo "VSIX validation passed. File size: $FILE_SIZE bytes"
137-
160+
138161 # Determine if this is a pre-release
139162 - name : Check if pre-release
140163 id : prerelease
@@ -146,7 +169,7 @@ jobs:
146169 echo "is_prerelease=false" >> $GITHUB_OUTPUT
147170 echo "This is a stable release"
148171 fi
149-
172+
150173 # Publish to VS Code Marketplace
151174 - name : Publish to VS Code Marketplace
152175 if : |
@@ -157,15 +180,15 @@ jobs:
157180 VSCE_PAT : ${{ secrets.VSCE_PAT }}
158181 run : |
159182 VSIX_FILE="${{ steps.package.outputs.vsix_file }}"
160-
183+
161184 if [[ "${{ steps.prerelease.outputs.is_prerelease }}" == "true" ]]; then
162185 echo "Publishing pre-release to VS Code Marketplace..."
163186 npx vsce publish --packagePath "$VSIX_FILE" --pre-release
164187 else
165188 echo "Publishing stable release to VS Code Marketplace..."
166189 npx vsce publish --packagePath "$VSIX_FILE"
167190 fi
168-
191+
169192 # Publish to Open VSX Registry
170193 - name : Publish to Open VSX Registry
171194 if : |
@@ -178,7 +201,7 @@ jobs:
178201 VSIX_FILE="${{ steps.package.outputs.vsix_file }}"
179202 echo "Publishing to Open VSX Registry..."
180203 npx ovsx publish "$VSIX_FILE" --pat $OVSX_PAT
181-
204+
182205 # Upload VSIX to GitHub Release
183206 - name : Upload VSIX to GitHub Release
184207 if : github.event_name == 'release'
@@ -189,7 +212,7 @@ jobs:
189212 generate_release_notes : true
190213 env :
191214 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
192-
215+
193216 # Upload as workflow artifact (for manual runs)
194217 - name : Upload VSIX as artifact
195218 if : github.event_name == 'workflow_dispatch'
@@ -198,7 +221,7 @@ jobs:
198221 name : vscode-extension-${{ github.run_number }}
199222 path : ${{ steps.package.outputs.vsix_file }}
200223 retention-days : 30
201-
224+
202225 # Summary
203226 - name : Release Summary
204227 run : |
@@ -209,4 +232,4 @@ jobs:
209232 echo "- **Open VSX Registry**: ${{ env.OVSX_PAT != '' && 'Published' || 'Skipped (no PAT)' }}" >> $GITHUB_STEP_SUMMARY
210233 env :
211234 VSCE_PAT : ${{ secrets.VSCE_PAT }}
212- OVSX_PAT : ${{ secrets.OVSX_PAT }}
235+ OVSX_PAT : ${{ secrets.OVSX_PAT }}
0 commit comments