panache 2.43.1

An LSP, formatter, and linter for Markdown, Quarto, and R Markdown
name: Publish Code Extensions

on:
  workflow_call:
    inputs:
      release-tag:
        description: "If set, download binaries from this GitHub release tag instead of same-run workflow artifacts"
        type: string
        required: false
        default: ""
  workflow_dispatch:
    inputs:
      release-tag:
        description: "Release tag to download binaries from"
        type: string
        required: true

concurrency:
  group: ${{ github.workflow }}-${{ inputs.release-tag || github.ref }}
  cancel-in-progress: true

jobs:
  publish-platform:
    name: Publish ${{ matrix.vsce_target }}
    runs-on: ubuntu-latest
    permissions:
      contents: read
    strategy:
      fail-fast: false
      matrix:
        include:
          - vsce_target: win32-x64
            rust_target: x86_64-pc-windows-msvc
            binary: panache.exe
          - vsce_target: win32-arm64
            rust_target: aarch64-pc-windows-msvc
            binary: panache.exe
          - vsce_target: linux-x64
            rust_target: x86_64-unknown-linux-gnu
            binary: panache
          - vsce_target: linux-arm64
            rust_target: aarch64-unknown-linux-gnu
            binary: panache
          - vsce_target: alpine-x64
            rust_target: x86_64-unknown-linux-musl
            binary: panache
          - vsce_target: alpine-arm64
            rust_target: aarch64-unknown-linux-musl
            binary: panache
          - vsce_target: darwin-x64
            rust_target: x86_64-apple-darwin
            binary: panache
          - vsce_target: darwin-arm64
            rust_target: aarch64-apple-darwin
            binary: panache
    steps:
      - uses: actions/checkout@v6

      - uses: actions/setup-node@v6
        with:
          node-version: 20
          cache: npm
          cache-dependency-path: editors/code/package-lock.json

      - name: Install dependencies
        working-directory: editors/code
        run: npm ci

      - name: Download binary (workflow artifact)
        if: ${{ inputs.release-tag == '' }}
        uses: actions/download-artifact@v8
        with:
          name: panache-binary-${{ matrix.rust_target }}
          path: editors/code/server

      - name: Download binary (release asset)
        if: ${{ inputs.release-tag != '' }}
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p editors/code/server
          cd editors/code/server
          if [[ "${{ matrix.binary }}" == *.exe ]]; then
            gh release download "${{ inputs.release-tag }}" -p "panache-${{ matrix.rust_target }}.zip" --repo "${{ github.repository }}"
            unzip -j "panache-${{ matrix.rust_target }}.zip" "${{ matrix.binary }}"
            rm "panache-${{ matrix.rust_target }}.zip"
          else
            gh release download "${{ inputs.release-tag }}" -p "panache-${{ matrix.rust_target }}.tar.gz" --repo "${{ github.repository }}"
            tar -xzf "panache-${{ matrix.rust_target }}.tar.gz" "./${{ matrix.binary }}"
            rm "panache-${{ matrix.rust_target }}.tar.gz"
          fi
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Mark binary executable
        run: chmod +x editors/code/server/${{ matrix.binary }}

      - name: Package VSIX
        working-directory: editors/code
        run: npx vsce package --target ${{ matrix.vsce_target }} -o panache-${{ matrix.vsce_target }}.vsix

      - name: Publish to Open VSX Registry
        uses: HaaLeo/publish-vscode-extension@v2
        with:
          pat: ${{ secrets.OVSX_PAT }}
          extensionFile: editors/code/panache-${{ matrix.vsce_target }}.vsix

      - name: Publish to Visual Studio Marketplace
        uses: HaaLeo/publish-vscode-extension@v2
        with:
          pat: ${{ secrets.VSCE_PAT }}
          registryUrl: https://marketplace.visualstudio.com
          extensionFile: editors/code/panache-${{ matrix.vsce_target }}.vsix