name: Build and Release

on:
  push:
    tags:
      - 'v*' # Triggers automatically when you push a tag like v1.0.0

jobs:
  build:
    runs-on: ubuntu-22.04 # Using an older LTS ensures maximum glibc compatibility
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential libsdl2-dev libsdl2-image-dev pkg-config

      - name: Compile binary
        run: make

      - name: Rename binary for distribution
        run: mv game-splash game-splash-linux-x86_64

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: game-splash-linux-x86_64
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}