name: Build Windows Release

on:
  push:
    tags:
      - 'v*'

jobs:
  build:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: pip install -e . pyinstaller

      - name: Build executable
        run: pyinstaller packaging/isc.spec

      - name: Stage release artifacts
        shell: bash
        run: |
          mkdir -p "releases/${{ github.ref_name }}"
          cp -r dist/ISC/* "releases/${{ github.ref_name }}/"

      - name: Commit and push release
        shell: bash
        run: |
          git config user.name "CI Bot"
          git config user.email "ci@isensecloud.com"
          git add "releases/${{ github.ref_name }}/"
          git commit -m "release: ${{ github.ref_name }} artifacts" || echo "No changes to commit"
          git push
