Skip to content

Commit dd61140

Browse files
committed
fix: clean up ci steps
1 parent 5e1cef1 commit dd61140

2 files changed

Lines changed: 119 additions & 153 deletions

File tree

.github/workflows/ci.yml

Lines changed: 119 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,133 @@ name: CI
33
on:
44
push:
55
branches: [ main ]
6+
tags:
7+
- 'vscode-v*'
68
pull_request:
79
branches: [ main ]
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Version to release (e.g., 0.1.0)'
14+
required: true
15+
type: string
816

917
jobs:
1018
test:
11-
name: Test
19+
name: Lint and Test
1220
runs-on: ubuntu-latest
13-
21+
# Only run on PRs, main branch pushes, or manual trigger
22+
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
23+
1424
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Setup Node.js
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version: '20'
21-
cache: 'npm'
22-
23-
- name: Install Xvfb
24-
run: |
25-
sudo apt-get update
26-
sudo apt-get install -y xvfb
25+
- name: Checkout Repository
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '20'
32+
cache: 'npm'
33+
34+
- name: Install Dependencies
35+
run: |
36+
npm install --no-fund --no-audit
37+
cd webview-ui
38+
npm install --no-fund --no-audit
39+
40+
- name: Lint
41+
run: |
42+
npm run lint
43+
44+
- name: Install Xvfb
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y xvfb
48+
49+
- name: Run Tests with Xvfb
50+
run: |
51+
xvfb-run -a npm run test-all
2752
28-
- name: Install dependencies
29-
run: npm ci
53+
- name: Build webview
54+
run: npm run build-webview
3055

31-
- name: Run linting
32-
run: npm run lint
56+
- name: Compile extension
57+
run: npm run compile
3358

34-
- name: Run tests with Xvfb
35-
run: xvfb-run -a npm run test-all
36-
37-
- name: Build webview
38-
run: npm run build-webview
59+
release:
60+
name: Build and Release Extension
61+
needs: test
62+
runs-on: ubuntu-latest
63+
# Only run on tags or manual trigger
64+
if: startsWith(github.ref, 'refs/tags/vscode-v') || github.event_name == 'workflow_dispatch'
65+
66+
steps:
67+
- name: Checkout Repository
68+
uses: actions/checkout@v4
69+
70+
- name: Setup Node.js
71+
uses: actions/setup-node@v4
72+
with:
73+
node-version: '20'
74+
75+
- name: Determine Version
76+
id: version
77+
run: |
78+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
79+
VERSION="${{ github.event.inputs.version }}"
80+
else
81+
# Extract version from tag (remove 'vscode-v' prefix)
82+
VERSION="${GITHUB_REF#refs/tags/vscode-v}"
83+
fi
84+
echo "version=$VERSION" >> $GITHUB_OUTPUT
85+
echo "Using version: $VERSION"
86+
87+
- name: Install Dependencies
88+
run: |
89+
npm install --no-fund --no-audit
90+
cd webview-ui
91+
npm install --no-fund --no-audit
92+
93+
- name: Update Version
94+
run: |
95+
sed -i "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"${{ steps.version.outputs.version }}\"/" package.json
96+
97+
- name: Install Xvfb
98+
run: |
99+
sudo apt-get update
100+
sudo apt-get install -y xvfb
101+
102+
- name: Package Extension
103+
run: |
104+
mkdir -p dist
105+
# Use xvfb for compile step in case it launches VS Code
106+
xvfb-run -a npm run compile
107+
npx @vscode/vsce package --no-dependencies --no-yarn -o dist/goose-vscode-${{ steps.version.outputs.version }}.vsix
108+
109+
# Verify the package was created
110+
if [ ! -f "dist/goose-vscode-${{ steps.version.outputs.version }}.vsix" ]; then
111+
echo "Failed to create the VSIX package"
112+
exit 1
113+
fi
114+
115+
- name: Create Release
116+
id: create_release
117+
uses: softprops/action-gh-release@v1
118+
if: startsWith(github.ref, 'refs/tags/vscode-v')
119+
with:
120+
name: VS Code Extension v${{ steps.version.outputs.version }}
121+
draft: false
122+
prerelease: false
123+
files: dist/*.vsix
124+
tag_name: ${{ github.ref_name }}
125+
generate_release_notes: true
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39128

40-
- name: Compile extension
41-
run: npm run compile
129+
- name: Publish to VS Code Marketplace
130+
id: publish_vscode_marketplace
131+
if: startsWith(github.ref, 'refs/tags/vscode-v')
132+
env:
133+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
134+
run: |
135+
npx vsce publish --pat $VSCE_PAT

.github/workflows/vscode-extension.yml

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)