name: Build source tars
on:
  release:
    types: ["published"]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Run build-source.sh
        run: |
          set -x
          ./build-source.sh
          assets=()
          for asset in ./MangoHud-*-Source*.tar.gz; do
            assets+=("-a" "$asset")
          done
          tag_name="${GITHUB_REF##*/}"
          hub release create "${assets[@]}" -m "$tag_name" "$tag_name"

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
