name: Release on PGXN
on:
  push:
    branches:
      - "**"
jobs:
  release:
    name: Release on PGXN
    runs-on: ubuntu-latest
    container: pgxn/pgxn-tools
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Bundle the Release
        run: pgxn-bundle
      - name: Release on PGXN
        env:
          MAIN_BRANCH: pgxn-citus
          PGXN_USERNAME: ${{ secrets.PGXN_USER_NAME }}
          PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }}
        run: |
          CURRENT_BRANCH="${GITHUB_REF##*/}"
          if [ "${CURRENT_BRANCH}" = "${MAIN_BRANCH}" ]
          then
            pgxn-release
          else
            echo "Distro will not be released since current branch '${CURRENT_BRANCH}' is different from main branch '${MAIN_BRANCH}'"
          fi
