|
| 1 | +name: VSCode Extension |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['vscode-v*'] |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + - 'editors/vscode/**' |
| 9 | + - 'sqlshield-lsp/**' |
| 10 | + - 'sqlshield/**' |
| 11 | + - '.github/workflows/vscode.yml' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + package: |
| 19 | + name: package (${{ matrix.target.vsce }}) |
| 20 | + runs-on: ${{ matrix.target.runner }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + target: |
| 25 | + - { runner: ubuntu-latest, rust: x86_64-unknown-linux-gnu, vsce: linux-x64, use_cross: false } |
| 26 | + - { runner: ubuntu-latest, rust: aarch64-unknown-linux-gnu, vsce: linux-arm64, use_cross: true } |
| 27 | + - { runner: macos-14, rust: aarch64-apple-darwin, vsce: darwin-arm64, use_cross: false } |
| 28 | + - { runner: macos-14, rust: x86_64-apple-darwin, vsce: darwin-x64, use_cross: false } |
| 29 | + - { runner: windows-latest, rust: x86_64-pc-windows-msvc, vsce: win32-x64, use_cross: false } |
| 30 | + - { runner: windows-latest, rust: aarch64-pc-windows-msvc, vsce: win32-arm64, use_cross: false } |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - uses: dtolnay/rust-toolchain@stable |
| 35 | + with: |
| 36 | + targets: ${{ matrix.target.rust }} |
| 37 | + |
| 38 | + - uses: Swatinem/rust-cache@v2 |
| 39 | + with: |
| 40 | + key: vsce-${{ matrix.target.vsce }} |
| 41 | + |
| 42 | + - name: Install cross |
| 43 | + if: matrix.target.use_cross |
| 44 | + run: cargo install cross --locked |
| 45 | + |
| 46 | + - name: Build sqlshield-lsp (cross) |
| 47 | + if: matrix.target.use_cross |
| 48 | + run: cross build -p sqlshield-lsp --release --target ${{ matrix.target.rust }} |
| 49 | + |
| 50 | + - name: Build sqlshield-lsp (native / rustup target) |
| 51 | + if: ${{ !matrix.target.use_cross }} |
| 52 | + run: cargo build -p sqlshield-lsp --release --target ${{ matrix.target.rust }} |
| 53 | + |
| 54 | + - name: Stage binary into extension |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + mkdir -p editors/vscode/server |
| 58 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 59 | + cp target/${{ matrix.target.rust }}/release/sqlshield-lsp.exe editors/vscode/server/sqlshield-lsp.exe |
| 60 | + else |
| 61 | + cp target/${{ matrix.target.rust }}/release/sqlshield-lsp editors/vscode/server/sqlshield-lsp |
| 62 | + chmod +x editors/vscode/server/sqlshield-lsp |
| 63 | + fi |
| 64 | +
|
| 65 | + - uses: actions/setup-node@v4 |
| 66 | + with: |
| 67 | + node-version: '20' |
| 68 | + cache: 'npm' |
| 69 | + cache-dependency-path: editors/vscode/package-lock.json |
| 70 | + |
| 71 | + - name: Install extension dependencies |
| 72 | + working-directory: editors/vscode |
| 73 | + run: npm ci |
| 74 | + |
| 75 | + - name: Compile extension |
| 76 | + working-directory: editors/vscode |
| 77 | + run: npm run compile |
| 78 | + |
| 79 | + - name: Package VSIX |
| 80 | + working-directory: editors/vscode |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + mkdir -p ../../dist |
| 84 | + npx --yes @vscode/vsce package \ |
| 85 | + --target ${{ matrix.target.vsce }} \ |
| 86 | + --out ../../dist/sqlshield-${{ matrix.target.vsce }}.vsix |
| 87 | +
|
| 88 | + - uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: vsix-${{ matrix.target.vsce }} |
| 91 | + path: dist/*.vsix |
| 92 | + if-no-files-found: error |
| 93 | + |
| 94 | + publish: |
| 95 | + name: publish to marketplaces |
| 96 | + needs: package |
| 97 | + runs-on: ubuntu-latest |
| 98 | + if: startsWith(github.ref, 'refs/tags/vscode-v') |
| 99 | + permissions: |
| 100 | + contents: write |
| 101 | + env: |
| 102 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 103 | + OVSX_PAT: ${{ secrets.OVSX_PAT }} |
| 104 | + steps: |
| 105 | + - uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - uses: actions/setup-node@v4 |
| 108 | + with: |
| 109 | + node-version: '20' |
| 110 | + cache: 'npm' |
| 111 | + cache-dependency-path: editors/vscode/package-lock.json |
| 112 | + |
| 113 | + - uses: actions/download-artifact@v4 |
| 114 | + with: |
| 115 | + path: dist |
| 116 | + pattern: vsix-* |
| 117 | + merge-multiple: true |
| 118 | + |
| 119 | + - name: List VSIX files |
| 120 | + run: ls -lh dist/ |
| 121 | + |
| 122 | + - name: Publish to VS Code Marketplace |
| 123 | + working-directory: editors/vscode |
| 124 | + run: | |
| 125 | + for vsix in ../../dist/*.vsix; do |
| 126 | + echo "Publishing $vsix" |
| 127 | + npx --yes @vscode/vsce publish --packagePath "$vsix" |
| 128 | + done |
| 129 | +
|
| 130 | + - name: Publish to Open VSX |
| 131 | + if: ${{ env.OVSX_PAT != '' }} |
| 132 | + working-directory: editors/vscode |
| 133 | + run: | |
| 134 | + for vsix in ../../dist/*.vsix; do |
| 135 | + echo "Publishing $vsix to Open VSX" |
| 136 | + npx --yes ovsx publish "$vsix" -p "$OVSX_PAT" |
| 137 | + done |
0 commit comments