name: Arduino Pong CD

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

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

      - name: Install Arduino CLI
        run: |
          curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
          echo "./bin" >> $GITHUB_PATH

      - name: Install Board Core and Libs
        run: |
          arduino-cli core update-index
          arduino-cli core install arduino:renesas_uno

      - name: Build Binary
        run: make compile

      - name: Create Release
        uses: softprops/action-gh-release@v2
        with:
          files: |
            build/*.bin
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
