Elffuss BraidHub

kikocis/continue public

2ff6e1c400a1 · 7.1 KiBRawPermalink
1name: Publish Extension
2
3on:
4 release:
5 types: [released]
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.0.*-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 - name: Make sure version isn't odd
79 run: |
80 cd extensions/vscode
81 node scripts/versionCheck.js
82
83 # 2. Install npm dependencies
84 - name: Use Node.js from .nvmrc
85 uses: actions/setup-node@v4
86 with:
87 node-version-file: ".nvmrc"
88
89 - name: Cache extension node_modules
90 uses: actions/cache@v3
91 with:
92 path: extensions/vscode/node_modules
93 key: ${{ runner.os }}-node-${{ hashFiles('extensions/vscode/package-lock.json') }}
94
95 - name: Cache core node_modules
96 uses: actions/cache@v3
97 with:
98 path: core/node_modules
99 key: ${{ runner.os }}-node-${{ hashFiles('core/package-lock.json') }}
100
101 - name: Cache gui node_modules
102 uses: actions/cache@v3
103 with:
104 path: gui/node_modules
105 key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
106
107 - name: Install extension Dependencies
108 run: |
109 cd extensions/vscode
110 npm ci
111 env:
112 # https://github.com/microsoft/vscode-ripgrep/issues/9#issuecomment-643965333
113 GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
114
115 - name: Install gui Dependencies
116 run: |
117 cd gui
118 npm ci
119
120 # npm ci doesn't end up capturing the @lancedb/... dep because it's not in the package-lock.json
121 - name: Install Core Dependencies
122 run: |
123 cd core
124 npm ci
125 npm i vectordb
126
127 # - name: Run core tests
128 # run: |
129 # cd core
130 # npm run test
131 # env:
132 # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
133
134 # 2.5. Pre package
135 - name: Set var for environment info
136 shell: pwsh
137 run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
138
139 - name: Prepackage the extension
140 run: |
141 cd extensions/vscode
142 npm run prepackage -- --target ${{ env.target }}
143
144 # 3. Re-install esbuild (for cases that we force installed for another arch in prepackage.js)
145 - name: Re-install esbuild
146 run: |
147 cd extensions/vscode
148 npm install -f esbuild
149
150 # 4. Run tests for the extension
151 # - name: Install Xvfb for Linux and run tests
152 # run: |
153 # sudo apt-get install -y xvfb # Install Xvfb
154 # Xvfb :99 & # Start Xvfb
155 # export DISPLAY=:99 # Export the display number to the environment
156 # cd extensions/vscode
157 # npm run test
158 # if: matrix.os == 'ubuntu-latest'
159
160 # - name: Run extension tests
161 # run: |
162 # cd extensions/vscode
163 # npm run test
164 # if: matrix.os != 'ubuntu-latest'
165
166 # 5. Package the extension
167 - name: Package the extension
168 run: cd extensions/vscode && npx vsce package --no-dependencies --target ${{ env.target }}
169
170 # 6. Upload the .vsix as an artifact
171 - uses: actions/upload-artifact@v4
172 with:
173 name: ${{ env.target }}-vsix
174 path: "extensions/vscode/*.vsix"
175
176 release:
177 permissions:
178 contents: write
179 runs-on: ubuntu-latest
180 needs:
181 - build
182 steps:
183 - name: Checkout
184 uses: actions/checkout@v4
185
186 - name: Set up Git
187 run: |
188 git config --local user.email "action@github.com"
189 git config --local user.name "GitHub Action"
190
191 # Download the .vsix artifacts
192 - uses: actions/download-artifact@v4
193 with:
194 pattern: "*-vsix"
195 path: vsix-artifacts
196 merge-multiple: true
197
198 - name: Release
199 uses: softprops/action-gh-release@v2
200 with:
201 tag_name: ${{ github.ref_name }}
202 files: |
203 vsix-artifacts/*.vsix
204 token: ${{ secrets.CI_GITHUB_TOKEN }}
205 repository: continuedev/continue
206
207 publish:
208 runs-on: ubuntu-latest
209 needs:
210 - build
211 if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
212 permissions:
213 contents: write
214 steps:
215 # 0. Setup git
216 - name: Checkout
217 uses: actions/checkout@v4
218
219 - name: Set up Git
220 run: |
221 git config --local user.email "action@github.com"
222 git config --local user.name "GitHub Action"
223
224 - name: Pull latest changes from release
225 run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }}
226
227 # 1. Download the artifacts
228 - uses: actions/download-artifact@v4
229 with:
230 pattern: "*-vsix"
231 path: vsix-artifacts
232 merge-multiple: true
233
234 # 2. Publish the extension to VS Code Marketplace
235 - name: Publish to VS Code Marketplace
236 run: |
237 cd extensions/vscode
238 npx @vscode/vsce publish --packagePath ../../vsix-artifacts/*.vsix
239 env:
240 VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
241
242 # 3. Publish the extension to Open VSX Registry
243 - name: Publish (Open VSX Registry)
244 continue-on-error: true
245 run: |
246 cd extensions/vscode
247 npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix