Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 路 9.1 KiBRawPermalink
1name: Publish Pre-release Extension
2
3on:
4 release:
5 types: [prereleased]
6
7 workflow_dispatch:
8 inputs:
9 publish_build:
10 description: "Whether or not to publish the built extension to the VS Code marketplace"
11 required: true
12 default: false
13
14jobs:
15 check_release_name:
16 runs-on: ubuntu-latest
17 outputs:
18 should_run: ${{ steps.check.outputs.should_run }}
19 steps:
20 - id: check
21 working-directory: .
22 run: |
23 if [[ "${{ github.event.release.tag_name }}" == v1.1.*-vscode ]]; then
24 echo "should_run=true" >> $GITHUB_OUTPUT
25 else
26 echo "should_run=false" >> $GITHUB_OUTPUT
27 fi
28
29 build:
30 needs: check_release_name
31 if: needs.check_release_name.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
32 strategy:
33 matrix:
34 include:
35 - os: windows-latest
36 platform: win32
37 arch: x64
38 npm_config_arch: x64
39 - os: windows-latest
40 platform: win32
41 arch: arm64
42 npm_config_arch: arm
43 - os: ubuntu-latest
44 platform: linux
45 arch: x64
46 npm_config_arch: x64
47 - os: ubuntu-latest
48 platform: linux
49 arch: arm64
50 npm_config_arch: arm64
51 - os: ubuntu-latest
52 platform: linux
53 arch: armhf
54 npm_config_arch: arm
55 - os: ubuntu-latest
56 platform: alpine
57 arch: x64
58 npm_config_arch: x64
59 - os: macos-13
60 platform: darwin
61 arch: x64
62 npm_config_arch: x64
63 - os: macos-13
64 platform: darwin
65 arch: arm64
66 npm_config_arch: arm64
67 runs-on: ${{ matrix.os }}
68 steps:
69 # 1. Check-out repository
70 - name: Checkout
71 uses: actions/checkout@v4
72 with:
73 fetch-depth: 0 # This ensures all tags are fetched
74
75 - name: Checkout tag
76 run: git checkout ${GITHUB_REF#refs/tags/}
77
78 # 2. Install npm dependencies
79 - name: Use Node.js from .nvmrc
80 uses: actions/setup-node@v4
81 with:
82 node-version-file: ".nvmrc"
83
84 - name: Cache extension node_modules
85 uses: actions/cache@v3
86 with:
87 path: extensions/vscode/node_modules
88 key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
89
90 - name: Cache core node_modules
91 uses: actions/cache@v3
92 with:
93 path: core/node_modules
94 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
95
96 - name: Cache gui node_modules
97 uses: actions/cache@v3
98 with:
99 path: gui/node_modules
100 key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
101
102 - name: Build packages (Windows)
103 run: ./scripts/build-packages.ps1
104 if: matrix.os == 'windows-latest'
105
106 - name: Build packages (Unix)
107 run: ./scripts/build-packages.sh
108 if: matrix.os != 'windows-latest'
109
110 - name: Install extension Dependencies
111 run: |
112 cd extensions/vscode
113 npm ci
114 env:
115 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
116 GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
117
118 - name: Install gui Dependencies
119 run: |
120 cd gui
121 npm ci
122
123 # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
124 - name: Install Core Dependencies
125 run: |
126 cd core
127 npm ci
128 npm i vectordb
129
130 # - name: Run core tests
131 # run: |
132 # cd core
133 # npm run test
134 # env:
135 # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
136
137 # 2.5. Pre package
138 - name: Set var for environment info
139 shell: pwsh
140 run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
141
142 - name: Prepackage the extension
143 run: |
144 cd extensions/vscode
145 npm run prepackage -- --target ${{ env.target }}
146
147 # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
148 - name: Re-install esbuild
149 run: |
150 cd extensions/vscode
151 npm install -f esbuild
152
153 # 4. Run tests for the extension
154 # - name: Install Xvfb for Linux and run tests
155 # run: |
156 # sudo apt-get install -y xvfb # Install Xvfb
157 # Xvfb :99 & # Start Xvfb
158 # export DISPLAY=:99 # Export the display number to the environment
159 # cd extensions/vscode
160 # npm run test
161 # if: matrix.os == 'ubuntu-latest'
162
163 # - name: Run extension tests
164 # run: |
165 # cd extensions/vscode
166 # npm run test
167 # if: matrix.os != 'ubuntu-latest'
168
169 # 5. Package the extension
170 - name: Package the extension
171 run: cd extensions/vscode && npx vsce package --pre-release --no-dependencies --target ${{ env.target }}
172
173 # 6. Upload the .vsix as an artifact
174 - uses: actions/upload-artifact@v4
175 with:
176 name: ${{ env.target }}-vsix
177 path: "extensions/vscode/*.vsix"
178
179 release:
180 permissions:
181 contents: write
182 runs-on: ubuntu-latest
183 needs:
184 - build
185 steps:
186 - name: Checkout
187 uses: actions/checkout@v4
188
189 - name: Set up Git
190 run: |
191 git config --local user.email "action@github.com"
192 git config --local user.name "GitHub Action"
193
194 # Download the .vsix artifacts
195 - uses: actions/download-artifact@v4
196 with:
197 pattern: "*-vsix"
198 path: vsix-artifacts
199 merge-multiple: true
200
201 - name: Release
202 uses: softprops/action-gh-release@v2
203 with:
204 tag_name: ${{ github.ref_name }}
205 files: |
206 vsix-artifacts/*.vsix
207 token: ${{ secrets.CI_GITHUB_TOKEN }}
208 repository: continuedev/continue
209 prerelease: true
210
211 publish:
212 runs-on: ubuntu-latest
213 needs:
214 - build
215 if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
216 permissions:
217 contents: write
218 pull-requests: write
219 steps:
220 # 0. Setup git
221 - name: Checkout
222 uses: actions/checkout@v4
223
224 - name: Set up Git
225 run: |
226 git config --local user.email "action@github.com"
227 git config --local user.name "GitHub Action"
228
229 - name: Pull latest changes from release
230 run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
231
232 # 1. Download the artifacts
233 - uses: actions/download-artifact@v4
234 with:
235 pattern: "*-vsix"
236 path: vsix-artifacts
237 merge-multiple: true
238
239 # 2. Publish the extension to VS Code Marketplace
240 - name: Publish to VS Code Marketplace
241 run: |
242 cd extensions/vscode
243 npx @vscode/vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix
244 env:
245 VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
246
247 # 3. Publish the extension to Open VSX Registry
248 - name: Publish (Open VSX Registry)
249 continue-on-error: true
250 run: |
251 cd extensions/vscode
252 npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix
253
254 # 4. Create PR with version bump
255 - name: Setup Node.js
256 uses: actions/setup-node@v4
257 with:
258 node-version-file: ".nvmrc"
259
260 - name: Create PR branch
261 run: |
262 BRANCH_NAME="chore/bump-vscode-version-$(date +%Y%m%d-%H%M%S)"
263 git checkout -b $BRANCH_NAME
264 echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
265
266 - name: Bump version in package.json
267 run: |
268 cd extensions/vscode
269 npm version patch --no-git-tag-version
270 VERSION=$(node -p "require('./package.json').version")
271 echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV
272
273 - name: Create Pull Request
274 uses: peter-evans/create-pull-request@v7
275 with:
276 token: ${{ secrets.CI_GITHUB_TOKEN }}
277 commit-message: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
278 title: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
279 body: |
280 Automated PR to bump the VS Code extension version after successful pre-release publication.
281
282 - Bumped version in extensions/vscode/package.json to ${{ env.NEW_VERSION }}
283 branch: ${{ env.BRANCH_NAME }}
284 base: main
285 delete-branch: true
286
287 # 5. Update version in package.json
288 # - name: Update version in package.json
289 # run: |
290 # cd extensions/vscode
291 # npm version patch
292 # - name: Commit changes
293 # run: |
294 # git config --local user.email "action@github.com"
295 # git config --local user.name "GitHub Action"
296 # git commit -am "馃挌 Update package.json version [skip ci]"
297
298 # - name: Push changes
299 # uses: ad-m/github-push-action@master
300 # with:
301 # github_token: ${{ secrets.GITHUB_TOKEN }}
302 # branch: ${{ github.ref }}