name: Publish pyservicenow package to PyPI

on:
  release:
    types:
      - published

jobs:
  publish:
    name: Create release and publish distribution to PyPI
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Python 3.11
        uses: actions/setup-python@v4
        with:
          python-version: 3.11
      - name: Install flit
        run: |
          pip install flit
      - name: Publish the distibution to PyPI
        if: github.repository == 'michaeldcanady/pyrestsdk'
        run: flit publish
        env:
          FLIT_INDEX_URL: https://upload.pypi.org/legacy/
          FLIT_USERNAME: __token__
          FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
