name: Publish

on:
  release:
    types:
      - created

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.6"
      - uses: actions/cache@v2
        id: cache
        with:
          path: ${{ env.pythonLocation }}
          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
      - name: Install Flit
        if: steps.cache.outputs.cache-hit != 'true'
        run: pip install flit
      - name: Install Dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: flit install --symlink
      - name: Publish
        env:
          FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
          FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
        run: bash scripts/publish.sh
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      # - name: Notify
      #   env:
      #     GITTER_TOKEN: ${{ secrets.GITTER_TOKEN }}
      #     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      #     TAG: ${{ github.event.release.name }}
      #   run: bash scripts/notify.sh
