name: Build & Release

on:
  push:
    branches:
      - main

jobs:
  build-windows:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-msvc

      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            src-tauri/target
          key: windows-cargo-${{ hashFiles('**/Cargo.lock') }}

      - run: npm install

      - uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
          CARGO_BUILD_JOBS: "2"
        with:
          tagName: ${{ github.ref_name }}
          releaseName: RLidentity ${{ github.ref_name }}
          releaseBody: New release
          releaseDraft: false
