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