name: test-build
on: [push]
jobs:
  test-build:
    runs-on: ubuntu-latest
    env:
      SDL_VERSION: 2.0.22
      IMG_VERSION: 2.0.5
      MIX_VERSION: 2.0.4
      TTF_VERSION: 2.0.18
      GFX_VERSION: 1.0.4
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          go-version: '1.13.15'
      - run: go version

      - name: Cache SDL2
        id: cache-sdl2
        uses: actions/cache@v3
        with:
          path: |
            SDL2-$SDL_VERSION
            IMG-$IMG_VERSION
            MIX-$MIX_VERSION
            TTF-$TTF_VERSION
            GFX-$GFX_VERSION
          key: ${{ runner.os }}-sdl2-${{ hashFiles('**/*.h') }}
          restore-keys: |
            ${{ runner.os }}-sdl2-

      - name: Cache Go
        id: cache-go
        uses: actions/cache@v3
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-

      - name: set PKG_CONFIG_PATH environment variable
        run: |
          echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV

      - name: Download, build, and install SDL2 packages
        run: |
          wget https://www.libsdl.org/release/SDL2-$SDL_VERSION.tar.gz
          tar xf SDL2-$SDL_VERSION.tar.gz
          cd SDL2-$SDL_VERSION
          ./configure --prefix=$HOME/.local
          make install
          cd ..
          wget https://excellmedia.dl.sourceforge.net/project/sdl2gfx/SDL2_gfx-$GFX_VERSION.tar.gz
          tar xf SDL2_gfx-$GFX_VERSION.tar.gz
          cd SDL2_gfx-$GFX_VERSION
          ./configure --prefix=$HOME/.local
          make install
          cd ..
          wget https://www.libsdl.org/projects/SDL_image/release/SDL2_image-$IMG_VERSION.tar.gz
          tar xf SDL2_image-$IMG_VERSION.tar.gz
          cd SDL2_image-$IMG_VERSION
          ./configure --prefix=$HOME/.local
          make install
          cd ..
          wget https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-$MIX_VERSION.tar.gz
          tar xf SDL2_mixer-$MIX_VERSION.tar.gz
          cd SDL2_mixer-$MIX_VERSION
          ./configure --prefix=$HOME/.local
          make install
          cd ..
          wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$TTF_VERSION.tar.gz
          tar xf SDL2_ttf-$TTF_VERSION.tar.gz
          cd SDL2_ttf-$TTF_VERSION
          ./configure --prefix=$HOME/.local
          make install
          cd ..

      - name: Test if Go-SDL2 works with the SDL2 packages
        run: |
          go build ./{sdl,gfx,img,mix,ttf}

Set up Github Actions as alternative to Travis CI
Set up Github Actions as alternative to Travis CI

Signed-off-by: Lilis Iskandar <f9acb790f2c75b127492316321ece0121b8eed9b@veand.co>
