-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (159 loc) · 5.47 KB
/
ci.yml
File metadata and controls
188 lines (159 loc) · 5.47 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
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
jobs:
build-and-test:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Compile TypeScript
run: npm run compile
- name: Setup virtual display (Linux only)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y xvfb
- name: Run tests
shell: bash
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
xvfb-run --auto-servernum --server-args='-screen 0 1280x1024x24' npm test
else
npm test
fi
env:
CI: true
auto-release:
name: Auto Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
needs: build-and-test
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Determine next version
id: version
uses: actions/github-script@v7
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({ owner: context.repo.owner, repo: context.repo.repo }).catch(()=>null);
let nextVersion;
if (latestRelease) {
const prevTagRaw = latestRelease.data.tag_name || '';
const prev = prevTagRaw.replace(/^v/, '');
const parts = prev.split('.');
if (parts.length !== 3 || parts.some(p => isNaN(Number(p)))) {
core.setFailed(`Latest release tag '${prevTagRaw}' is not semver x.y.z`);
return;
}
parts[2] = String(Number(parts[2]) + 1);
nextVersion = parts.join('.');
} else {
nextVersion = '0.0.1';
}
core.info(`Computed next version: ${nextVersion}`);
core.setOutput('version', nextVersion);
- name: Create and push tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
if git rev-parse ${VERSION} >/dev/null 2>&1; then echo "Tag ${VERSION} already exists"; else git tag ${VERSION}; git push origin ${VERSION}; fi
- name: Generate release notes & create release
uses: ./.github/actions/anthropic-release-notes
with:
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
language: en
model: claude-3-5-sonnet-latest
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.version.outputs.version }}
package:
name: Package Extension
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Package extension
run: vsce package
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: vsix-package
path: '*.vsix'
retention-days: 30
publish:
name: Publish to VS Code Marketplace
runs-on: ubuntu-latest
needs: package
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Sync package.json version to tag (no commit)
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
run: |
node -e "const fs=require('fs'); const tag=process.env.TAG_VERSION.replace(/^v/,''); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); if(pkg.version!==tag){ pkg.version=tag; fs.writeFileSync('package.json', JSON.stringify(pkg,null,2)+'\n'); console.log('Synced package.json version to tag', tag); } else { console.log('package.json version already matches tag', tag); }"
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: vsce publish -p $VSCE_PAT
- name: Download VSIX artifact
uses: actions/download-artifact@v4
with:
name: vsix-package
- name: Upload VSIX to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: '*.vsix'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}