Elffuss BraidHub

kikocis/continue public

e4890227bbc5 路 8.9 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: Install extension Dependencies
103 run: |
104 cd extensions/vscode
105 npm ci
106 env:
107 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
108 GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
109
110 - name: Install gui Dependencies
111 run: |
112 cd gui
113 npm ci
114
115 # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
116 - name: Install Core Dependencies
117 run: |
118 cd core
119 npm ci
120 npm i vectordb
121
122 # - name: Run core tests
123 # run: |
124 # cd core
125 # npm run test
126 # env:
127 # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
128
129 # 2.5. Pre package
130 - name: Set var for environment info
131 shell: pwsh
132 run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
133
134 - name: Prepackage the extension
135 run: |
136 cd extensions/vscode
137 npm run prepackage -- --target ${{ env.target }}
138
139 # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
140 - name: Re-install esbuild
141 run: |
142 cd extensions/vscode
143 npm install -f esbuild
144
145 # 4. Run tests for the extension
146 # - name: Install Xvfb for Linux and run tests
147 # run: |
148 # sudo apt-get install -y xvfb # Install Xvfb
149 # Xvfb :99 & # Start Xvfb
150 # export DISPLAY=:99 # Export the display number to the environment
151 # cd extensions/vscode
152 # npm run test
153 # if: matrix.os == 'ubuntu-latest'
154
155 # - name: Run extension tests
156 # run: |
157 # cd extensions/vscode
158 # npm run test
159 # if: matrix.os != 'ubuntu-latest'
160
161 # 5. Package the extension
162 - name: Package the extension
163 run: cd extensions/vscode && npx vsce package --pre-release --no-dependencies --target ${{ env.target }}
164
165 # 6. Upload the .vsix as an artifact
166 - uses: actions/upload-artifact@v4
167 with:
168 name: ${{ env.target }}-vsix
169 path: "extensions/vscode/*.vsix"
170
171 release:
172 permissions:
173 contents: write
174 runs-on: ubuntu-latest
175 needs:
176 - build
177 steps:
178 - name: Checkout
179 uses: actions/checkout@v4
180
181 - name: Set up Git
182 run: |
183 git config --local user.email "action@github.com"
184 git config --local user.name "GitHub Action"
185
186 # Download the .vsix artifacts
187 - uses: actions/download-artifact@v4
188 with:
189 pattern: "*-vsix"
190 path: vsix-artifacts
191 merge-multiple: true
192
193 - name: Release
194 uses: softprops/action-gh-release@v2
195 with:
196 tag_name: ${{ github.ref_name }}
197 files: |
198 vsix-artifacts/*.vsix
199 token: ${{ secrets.CI_GITHUB_TOKEN }}
200 repository: continuedev/continue
201 prerelease: true
202
203 publish:
204 runs-on: ubuntu-latest
205 needs:
206 - build
207 if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
208 permissions:
209 contents: write
210 pull-requests: write
211 steps:
212 # 0. Setup git
213 - name: Checkout
214 uses: actions/checkout@v4
215
216 - name: Set up Git
217 run: |
218 git config --local user.email "action@github.com"
219 git config --local user.name "GitHub Action"
220
221 - name: Pull latest changes from release
222 run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
223
224 # 1. Download the artifacts
225 - uses: actions/download-artifact@v4
226 with:
227 pattern: "*-vsix"
228 path: vsix-artifacts
229 merge-multiple: true
230
231 # 2. Publish the extension to VS Code Marketplace
232 - name: Publish to VS Code Marketplace
233 run: |
234 cd extensions/vscode
235 npx @vscode/vsce publish --pre-release --packagePath ../../vsix-artifacts/*.vsix
236 env:
237 VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
238
239 # 3. Publish the extension to Open VSX Registry
240 - name: Publish (Open VSX Registry)
241 continue-on-error: true
242 run: |
243 cd extensions/vscode
244 npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix
245
246 # 4. Create PR with version bump
247 - name: Setup Node.js
248 uses: actions/setup-node@v4
249 with:
250 node-version-file: ".nvmrc"
251
252 - name: Create PR branch
253 run: |
254 BRANCH_NAME="chore/bump-vscode-version-$(date +%Y%m%d-%H%M%S)"
255 git checkout -b $BRANCH_NAME
256 echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
257
258 - name: Bump version in package.json
259 run: |
260 cd extensions/vscode
261 npm version patch --no-git-tag-version
262 VERSION=$(node -p "require('./package.json').version")
263 echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV
264
265 - name: Create Pull Request
266 uses: peter-evans/create-pull-request@v7
267 with:
268 token: ${{ secrets.CI_GITHUB_TOKEN }}
269 commit-message: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
270 title: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
271 body: |
272 Automated PR to bump the VS Code extension version after successful pre-release publication.
273
274 - Bumped version in extensions/vscode/package.json to ${{ env.NEW_VERSION }}
275 branch: ${{ env.BRANCH_NAME }}
276 base: main
277 delete-branch: true
278
279 # 5. Update version in package.json
280 # - name: Update version in package.json
281 # run: |
282 # cd extensions/vscode
283 # npm version patch
284 # - name: Commit changes
285 # run: |
286 # git config --local user.email "action@github.com"
287 # git config --local user.name "GitHub Action"
288 # git commit -am "馃挌 Update package.json version [skip ci]"
289
290 # - name: Push changes
291 # uses: ad-m/github-push-action@master
292 # with:
293 # github_token: ${{ secrets.GITHUB_TOKEN }}
294 # branch: ${{ github.ref }}