name: "Build"

on:
  push:
    tags:
      - '*'

env:
  PROJECT_NAME: ${{ github.event.repository.name }}
  GODOT_VERSION: 3.2.3

jobs:
  build:
    runs-on: ubuntu-20.04
    container:
      image: barichello/godot-ci:3.2.3
    steps:
      - name: Install dependencies
        run: apt-get update && apt-get install -y rsync p7zip make
      - uses: actions/checkout@v2
      - name: Setup
        run: |
          mkdir -p ~/.local/share/godot/templates
          mv /root/.local/share/godot/templates/$GODOT_VERSION.stable ~/.local/share/godot/templates/$GODOT_VERSION.stable
      - name: Build Linux
        run: make linux
      - name: Build macOS
        run: make macos
      - name: Build Windows
        run: make windows
      - name: Clean up
        run: make clean-unzipped
      - name: Deploy Linux
        uses: josephbmanley/butler-publish-itchio-action@v1.0.2
        env:
          BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
          CHANNEL: linux
          ITCH_GAME: ${{ env.PROJECT_NAME }}
          ITCH_USER: blinry
          PACKAGE: build/${{ env.PROJECT_NAME }}-linux.zip
      - name: Deploy macOS
        uses: josephbmanley/butler-publish-itchio-action@v1.0.2
        env:
          BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
          CHANNEL: osx
          ITCH_GAME: ${{ env.PROJECT_NAME }}
          ITCH_USER: blinry
          PACKAGE: build/${{ env.PROJECT_NAME }}-macos.zip
      - name: Deploy Windows
        uses: josephbmanley/butler-publish-itchio-action@v1.0.2
        env:
          BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
          CHANNEL: windows
          ITCH_GAME: ${{ env.PROJECT_NAME }}
          ITCH_USER: blinry
          PACKAGE: build/${{ env.PROJECT_NAME }}-windows.zip
