name: Release ISO
on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Rust (1.88.0-nightly 2025-04-27)
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: nightly-2025-04-27
          override: true
          components: rust-src

      - name: Verify rustc version
        run: rustc -V

      - name: Install ISO build dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y mtools xorriso

      - name: cargo build --release (nel_os_bootloader)
        working-directory: nel_os_bootloader
        run: cargo build --release

      - name: create-iso.sh
        working-directory: nel_os_bootloader
        run: bash ./create-iso.sh ./target/x86_64-unknown-uefi/release/nel_os_bootloader.elf

      - name: Create Gitea Release & Upload ISO
        uses: akkuman/gitea-release-action@v1
        env:
          NODE_OPTIONS: '--experimental-fetch'
        with:
          server_url: ${{ github.server_url }}
          repository: ${{ github.repository }}
          tag_name: ${{ github.ref_name }}
          name: ${{ github.ref_name }}
          files: |
            nel_os_bootloader/nel_os.iso
          token: ${{ secrets.TOKEN }}

