name: Build & Publish

on:
  release:
    types:
    - created

jobs:
  Build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform: [linux, windows, osx]
    steps:
    - name: Checkout
      uses: actions/checkout@v1
    - name: Update Version
      id: semver
      uses: RightBrain-Networks/semver-action@1.0.0
      with:
        mode: get
    - name: Build
      id: build
      uses: josephbmanley/build-godot-action@v1.3.2
      with:
        name: glitchinthesystem
        preset: ${{ matrix.platform }}
        subdirectory: gits
    - name: GitHub Release Artifact
      uses: josephbmanley/upload-to-release@feature/remoteName
      with:
        args: ${{ steps.build.outputs.artifact }} application/zip ${{ matrix.platform }}.zip
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    - name: Butler Publish
      uses: josephbmanley/butler-publish-itchio-action@v1.0.0
      env:
        BUTLER_CREDENTIALS: ${{ secrets.BUTLER_CREDENTIALS }}
        VERSION: ${{ steps.semver.outputs.VERSION }}
        ITCH_USER: joebmanley
        ITCH_GAME: glitchinthesystem
        CHANNEL: ${{ matrix.platform }}
        PACKAGE: ${{ steps.build.outputs.artifact }}