|
| 1 | +name: Publish extension |
| 2 | + |
| 3 | +# Build a platform-specific .vsix on every push to the extension branch |
| 4 | +# (artifact-only, no publish). Publish to Open VSX only when a human pushes |
| 5 | +# a tag matching `extension-v*` — agents must never push tags per D-024. |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - feat/vscode-extension-** |
| 11 | + tags: |
| 12 | + - "extension-v*" |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - "extension/**" |
| 16 | + - ".github/workflows/publish-extension.yml" |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + name: Build .vsix (${{ matrix.target }}) |
| 25 | + runs-on: ${{ matrix.runner }} |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + include: |
| 30 | + - target: linux-x64 |
| 31 | + runner: ubuntu-latest |
| 32 | + binary_name: axme-code-linux-x64 |
| 33 | + extension_bin: axme-code |
| 34 | + - target: linux-arm64 |
| 35 | + runner: ubuntu-latest |
| 36 | + binary_name: axme-code-linux-arm64 |
| 37 | + extension_bin: axme-code |
| 38 | + - target: darwin-x64 |
| 39 | + runner: macos-13 |
| 40 | + binary_name: axme-code-darwin-x64 |
| 41 | + extension_bin: axme-code |
| 42 | + - target: darwin-arm64 |
| 43 | + runner: macos-latest |
| 44 | + binary_name: axme-code-darwin-arm64 |
| 45 | + extension_bin: axme-code |
| 46 | + - target: win32-x64 |
| 47 | + runner: windows-latest |
| 48 | + binary_name: axme-code-windows-x64.exe |
| 49 | + extension_bin: axme-code.exe |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - uses: actions/setup-node@v4 |
| 54 | + with: |
| 55 | + node-version: 20 |
| 56 | + cache: npm |
| 57 | + |
| 58 | + - name: Install core deps |
| 59 | + run: npm install |
| 60 | + |
| 61 | + - name: Build core |
| 62 | + run: npm run build |
| 63 | + |
| 64 | + - name: Bundle core CLI to a single platform-specific file |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + mkdir -p extension/bin |
| 68 | + # Bundle dist/cli.mjs into a single CJS file with all deps inlined |
| 69 | + # EXCEPT @cursor/sdk. claude-agent-sdk is always required (used by |
| 70 | + # LLM scanners during setup and by the session auditor); it must |
| 71 | + # be inside the binary so Node doesn't try to resolve it from a |
| 72 | + # node_modules/ dir that doesn't ship with the .vsix. |
| 73 | + # |
| 74 | + # @cursor/sdk stays external because (a) it carries ~15 MB of |
| 75 | + # platform-specific native binaries that bloat the .vsix, and |
| 76 | + # (b) the AgentSdk factory's fallback gracefully degrades to the |
| 77 | + # Claude path on MODULE_NOT_FOUND. v0.0.1 users use Claude for |
| 78 | + # the auditor; Cursor SDK as a first-class in-extension option |
| 79 | + # is a v0.0.2 follow-up. |
| 80 | + # |
| 81 | + # WHY CJS, not ESM: the output is a shebang script with no file |
| 82 | + # extension (Windows uses .exe — see matrix.extension_bin). |
| 83 | + # Without ".mjs" extension AND without a sibling package.json |
| 84 | + # declaring "type":"module", Node loads the file as CJS and |
| 85 | + # ESM import statements throw at runtime. |
| 86 | + npx esbuild dist/cli.mjs \ |
| 87 | + --bundle \ |
| 88 | + --platform=node \ |
| 89 | + --target=node20 \ |
| 90 | + --format=cjs \ |
| 91 | + --external:@cursor/sdk \ |
| 92 | + --outfile=extension/bin/axme-code.cjs |
| 93 | + # Wrap in a shebang shim so it's executable as a binary. |
| 94 | + { |
| 95 | + printf '#!/usr/bin/env node\n' |
| 96 | + cat extension/bin/axme-code.cjs |
| 97 | + } > extension/bin/${{ matrix.extension_bin }} |
| 98 | + rm extension/bin/axme-code.cjs |
| 99 | + chmod +x extension/bin/${{ matrix.extension_bin }} || true |
| 100 | +
|
| 101 | + - name: Install extension deps |
| 102 | + working-directory: extension |
| 103 | + run: npm install |
| 104 | + |
| 105 | + - name: Build extension bundle |
| 106 | + working-directory: extension |
| 107 | + run: npm run build |
| 108 | + |
| 109 | + - name: Package .vsix |
| 110 | + working-directory: extension |
| 111 | + run: npx vsce package --target ${{ matrix.target }} --no-dependencies -o ../axme-code-${{ matrix.target }}.vsix |
| 112 | + |
| 113 | + - uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: axme-code-${{ matrix.target }} |
| 116 | + path: axme-code-${{ matrix.target }}.vsix |
| 117 | + retention-days: 14 |
| 118 | + |
| 119 | + publish: |
| 120 | + name: Publish to Open VSX |
| 121 | + needs: build |
| 122 | + if: startsWith(github.ref, 'refs/tags/extension-v') |
| 123 | + runs-on: ubuntu-latest |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + - uses: actions/setup-node@v4 |
| 127 | + with: |
| 128 | + node-version: 20 |
| 129 | + |
| 130 | + - name: Download all .vsix artifacts |
| 131 | + uses: actions/download-artifact@v4 |
| 132 | + with: |
| 133 | + path: vsix |
| 134 | + merge-multiple: true |
| 135 | + |
| 136 | + - name: Publish per-target to Open VSX |
| 137 | + env: |
| 138 | + OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }} |
| 139 | + run: | |
| 140 | + set -euo pipefail |
| 141 | + for target in linux-x64 linux-arm64 darwin-x64 darwin-arm64 win32-x64; do |
| 142 | + file="vsix/axme-code-${target}.vsix" |
| 143 | + if [ ! -f "$file" ]; then |
| 144 | + echo "Warning: $file missing; skipping $target." |
| 145 | + continue |
| 146 | + fi |
| 147 | + echo "Publishing $file (target=$target)" |
| 148 | + npx ovsx publish "$file" --target "$target" --pat "$OVSX_TOKEN" |
| 149 | + done |
| 150 | +
|
| 151 | + - name: Attach .vsix files to GitHub Release |
| 152 | + env: |
| 153 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 154 | + run: | |
| 155 | + set -euo pipefail |
| 156 | + # Create release if missing, then attach all 5 .vsix files for |
| 157 | + # sideload distribution alongside Open VSX. |
| 158 | + tag="${GITHUB_REF#refs/tags/}" |
| 159 | + gh release view "$tag" >/dev/null 2>&1 || \ |
| 160 | + gh release create "$tag" --title "$tag" --notes "Extension $tag — six platform-specific .vsix files attached. See README for install instructions." |
| 161 | + for f in vsix/axme-code-*.vsix; do |
| 162 | + gh release upload "$tag" "$f" --clobber |
| 163 | + done |
0 commit comments