ime_shift_fix 0.1.0

Protect IME mode while selecting text with Shift+Click on Windows.
name: CI

on:
  push:
    branches: [ main, develop ]
    tags: [ 'v*' ]
  pull_request:
    branches: [ main, develop ]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  ci:
    name: Test, Format, Clippy, Build, Publish
    runs-on: windows-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: TheMrMilchmann/setup-msvc-dev@v4
        with:
          arch: x64

      - uses: Swatinem/rust-cache@v2

      - name: Run formatting
        run: cargo fmt --all

      - name: Run tests
        run: cargo test --verbose

      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Build release
        run: cargo build --release --verbose

      - name: Build documentation
        run: cargo doc --no-deps --document-private-items
        env:
          RUSTDOCFLAGS: -D warnings

      - name: Package crate
        run: cargo package --locked --verbose

      - name: Publish dry run
        run: cargo publish --dry-run --locked

      - name: Get crate name from Cargo.toml
        id: bin_name
        run: |

          $BIN_NAME = cargo metadata --no-deps --format-version 1 |
          ConvertFrom-Json |
          ForEach-Object { $_.packages[0].targets |
            Where-Object { $_.kind -contains 'bin' } |
            Select-Object -First 1 -ExpandProperty name }
          Add-Content -Path $env:GITHUB_OUTPUT -Value "bin_name=$BIN_NAME"

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ steps.bin_name.outputs.bin_name }}-release
          path: target/release/${{ steps.bin_name.outputs.bin_name }}.exe

      - name: Create GitHub release
        if: startsWith(github.ref, 'refs/tags/v')
        run: |

          gh release create "${{ github.ref_name }}" `
            "target/release/${{ steps.bin_name.outputs.bin_name }}.exe" `
            --title "${{ github.ref_name }}" `
            --generate-notes `
            --verify-tag
        env:
          GH_TOKEN: ${{ github.token }}

      - name: Publish to crates.io
        if: startsWith(github.ref, 'refs/tags/v')
        run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}