dprint-plugin-json 0.21.3

JSON formatter for dprint.
Documentation
name: CI

on: [push, pull_request]

jobs:
  build:
    name: ${{ matrix.config.kind }} ${{ matrix.config.os }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      matrix:
        config:
          - os: ubuntu-latest
            kind: test_release
          - os: ubuntu-latest
            kind: test_debug

    env:
      CARGO_INCREMENTAL: 0
      RUST_BACKTRACE: full

    steps:
    - uses: actions/checkout@v6
    - uses: dsherret/rust-toolchain-file@v1
    - name: Install wasm32 target
      if: matrix.config.kind == 'test_release'
      run: rustup target add wasm32-unknown-unknown

    - uses: Swatinem/rust-cache@v2
      with:
        save-if: ${{ github.ref == 'refs/heads/main' }}

    - name: Build debug
      if: matrix.config.kind == 'test_debug'
      run: cargo build
    - name: Build release
      if: matrix.config.kind == 'test_release'
      run: cargo build --target wasm32-unknown-unknown --features wasm --release

    - name: Test debug
      if: matrix.config.kind == 'test_debug'
      run: cargo test
    - name: Test release
      if: matrix.config.kind == 'test_release'
      run: cargo test --release

    - name: Get tag version
      if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
      id: get_tag_version
      run: echo ::set-output name=TAG_VERSION::${GITHUB_REF/refs\/tags\//}

    # NPM
    - uses: actions/setup-node@v6
      if: matrix.config.kind == 'test_release'
      with:
        node-version: '24.x'
        registry-url: 'https://registry.npmjs.org'

    - name: Setup and test npm deployment
      if: matrix.config.kind == 'test_release'
      run: |
        cd deployment/npm
        npm install
        node setup.js
        npm run test

      # GITHUB RELEASE
    - uses: denoland/setup-deno@v2
      if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
      with:
        deno-version: v2.x
    - name: Pre-release
      if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
      run: |
        # update config schema to have version
        sed -i 's/json\/0.0.0/json\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json
        # rename the wasm file
        (cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_json.wasm plugin.wasm)
        # create release notes
        deno run -A ./scripts/generate_release_notes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt
    - name: Release
      uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
      if: matrix.config.kind == 'test_release' && startsWith(github.ref, 'refs/tags/')
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        files: |
          target/wasm32-unknown-unknown/release/plugin.wasm
          deployment/schema.json
        body_path: ${{ github.workspace }}-CHANGELOG.txt
        draft: false