-
Notifications
You must be signed in to change notification settings - Fork 1
238 lines (206 loc) · 8.16 KB
/
Copy pathrelease.yml
File metadata and controls
238 lines (206 loc) · 8.16 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
# VS Code Extension Release Workflow - Final Fixed Version
name: Release VS Code Extension
on:
release:
types: [published, prereleased]
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- prerelease
marketplace_publish:
description: 'Publish to VS Code Marketplace'
required: false
default: true
type: boolean
openvsx_publish:
description: 'Publish to Open VSX Registry'
required: false
default: true
type: boolean
# Set permissions for the workflow
permissions:
contents: read
id-token: write
actions: read
security-events: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false # We'll handle installation manually for better caching
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install vsce and ovsx
run: |
pnpm add -D @vscode/vsce
pnpm add -D ovsx
# Setup headless environment for VS Code tests
- name: Setup headless environment
run: |
sudo apt-get update
sudo apt-get install -y xvfb libasound2-dev libgtk-3-dev libnss3-dev
# Run tests with xvfb for headless mode
- name: Run tests
run: |
export DISPLAY=:99.0
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
# Start D-Bus session
mkdir -p $XDG_RUNTIME_DIR
dbus-daemon --session --address=$DBUS_SESSION_BUS_ADDRESS --nofork --nopidfile --syslog-only &
# Start Xvfb with proper configuration
Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
# Wait for Xvfb to start
sleep 3
# Create VS Code config to disable hardware acceleration
mkdir -p ~/.vscode
echo '{ "disable-hardware-acceleration": true }' > ~/.vscode/argv.json
# Run tests
if [ -f "package.json" ] && grep -q '"test"' package.json; then
xvfb-run -a --server-args="-screen 0 1024x768x24 -ac +extension GLX +render -noreset" pnpm test
else
echo "No tests found, skipping test step"
fi
continue-on-error: false
# Build/compile if build script exists
- name: Build extension
run: |
if [ -f "package.json" ] && grep -q '"build"' package.json; then
pnpm run build
elif [ -f "package.json" ] && grep -q '"compile"' package.json; then
pnpm run compile
else
echo "No build/compile script found, skipping build step"
fi
# Package the extension with dependency fix
- name: Package extension
id: package
run: |
# Clean up any problematic dependencies first
npm ls --production --parseable --depth=99999 --loglevel=error || true
if [ -f "package.json" ] && grep -q '"package"' package.json; then
pnpm run package --no-dependencies
else
# Use vsce directly if no package script with production dependencies flag
npx vsce package --no-dependencies
fi
# Get the generated VSIX filename
VSIX_FILE=$(ls *.vsix | head -1)
echo "vsix_file=$VSIX_FILE" >> $GITHUB_OUTPUT
echo "Generated VSIX: $VSIX_FILE"
# Validate the package
- name: Validate package
run: |
VSIX_FILE="${{ steps.package.outputs.vsix_file }}"
if [ ! -f "$VSIX_FILE" ]; then
echo "ERROR: VSIX file not found: $VSIX_FILE"
exit 1
fi
# Check file size (should be reasonable)
FILE_SIZE=$(stat -c%s "$VSIX_FILE")
if [ $FILE_SIZE -lt 1000 ]; then
echo "ERROR: VSIX file seems too small: $FILE_SIZE bytes"
exit 1
fi
echo "VSIX validation passed. File size: $FILE_SIZE bytes"
# Determine if this is a pre-release
- name: Check if pre-release
id: prerelease
run: |
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "This is a pre-release"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "This is a stable release"
fi
# Publish to VS Code Marketplace
- name: Publish to VS Code Marketplace
if: |
(github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.marketplace_publish)) &&
env.VSCE_PAT != ''
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
VSIX_FILE="${{ steps.package.outputs.vsix_file }}"
if [[ "${{ steps.prerelease.outputs.is_prerelease }}" == "true" ]]; then
echo "Publishing pre-release to VS Code Marketplace..."
npx vsce publish --packagePath "$VSIX_FILE" --pre-release
else
echo "Publishing stable release to VS Code Marketplace..."
npx vsce publish --packagePath "$VSIX_FILE"
fi
# Publish to Open VSX Registry
- name: Publish to Open VSX Registry
if: |
(github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.openvsx_publish)) &&
env.OVSX_PAT != ''
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: |
VSIX_FILE="${{ steps.package.outputs.vsix_file }}"
echo "Publishing to Open VSX Registry..."
npx ovsx publish "$VSIX_FILE" --pat $OVSX_PAT
# Upload VSIX to GitHub Release
- name: Upload VSIX to GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.package.outputs.vsix_file }}
fail_on_unmatched_files: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload as workflow artifact (for manual runs)
- name: Upload VSIX as artifact
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: vscode-extension-${{ github.run_number }}
path: ${{ steps.package.outputs.vsix_file }}
retention-days: 30
# Summary
- name: Release Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Extension package**: ${{ steps.package.outputs.vsix_file }}" >> $GITHUB_STEP_SUMMARY
echo "- **Pre-release**: ${{ steps.prerelease.outputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY
echo "- **VS Code Marketplace**: ${{ env.VSCE_PAT != '' && 'Published' || 'Skipped (no PAT)' }}" >> $GITHUB_STEP_SUMMARY
echo "- **Open VSX Registry**: ${{ env.OVSX_PAT != '' && 'Published' || 'Skipped (no PAT)' }}" >> $GITHUB_STEP_SUMMARY
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}