name: Publish VS Code Extension # Decoupled from the binary `Release` workflow so the editor extension ships on # its own cadence. Trigger either by pushing a `vscode-v*` tag (e.g. vscode-v0.1.0) # or manually via the Actions tab with an explicit version. on: push: tags: - 'vscode-v*' workflow_dispatch: inputs: version: description: 'Extension version to publish (e.g. 0.1.0). Defaults to package.json.' required: false type: string permissions: contents: write jobs: publish-vscode: name: Package & publish (Marketplace + Open VSX) runs-on: ubuntu-latest defaults: run: working-directory: vscode-extension env: # Step-level `if` guards read these so the job still packages + uploads the # .vsix even before the publishing tokens are configured as repo secrets. VSCE_PAT: ${{ secrets.VSCE_PAT }} OVSX_PAT: ${{ secrets.OVSX_PAT }} steps: - uses: actions/checkout@v4 # v4 with: persist-credentials: false - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 - name: Install dependencies run: npm install - name: Resolve version id: ver run: | if [ -n "${{ inputs.version }}" ]; then VERSION="${{ inputs.version }}" elif [[ "${GITHUB_REF_NAME}" == vscode-v* ]]; then VERSION="${GITHUB_REF_NAME#vscode-v}" else VERSION="$(node -p "require('./package.json').version")" fi echo "version=${VERSION}" >> "$GITHUB_OUTPUT" npm version "${VERSION}" --no-git-tag-version --allow-same-version - name: Compile run: npm run compile - name: Package .vsix run: npx @vscode/vsce package --no-dependencies -o "${GITHUB_WORKSPACE}/lean-ctx-${{ steps.ver.outputs.version }}.vsix" - name: Publish to VS Code Marketplace if: ${{ env.VSCE_PAT != '' }} run: npx @vscode/vsce publish --packagePath "${GITHUB_WORKSPACE}/lean-ctx-${{ steps.ver.outputs.version }}.vsix" -p "${VSCE_PAT}" - name: Publish to Open VSX (Cursor / VSCodium / Windsurf) if: ${{ env.OVSX_PAT != '' }} run: npx ovsx publish "${GITHUB_WORKSPACE}/lean-ctx-${{ steps.ver.outputs.version }}.vsix" -p "${OVSX_PAT}" - name: Upload .vsix artifact uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: lean-ctx-vsix path: lean-ctx-*.vsix - name: Attach .vsix to GitHub release if: ${{ startsWith(github.ref, 'refs/tags/vscode-v') }} uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 with: tag_name: ${{ github.ref_name }} # Never let the extension release become the repo's "latest" — install.sh # and the npm postinstall resolve binaries via /releases/latest, so a # vscode-v* release hijacking "latest" breaks CLI installs (see #345). make_latest: false name: lean-ctx VS Code extension ${{ steps.ver.outputs.version }} files: lean-ctx-*.vsix body: | lean-ctx VS Code extension **${{ steps.ver.outputs.version }}**. Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=LeanCTX.lean-ctx) or [Open VSX](https://open-vsx.org/extension/LeanCTX/lean-ctx) (Cursor, VSCodium, Windsurf), or download the `.vsix` below and run `code --install-extension lean-ctx-${{ steps.ver.outputs.version }}.vsix`.