name: Publish nf-core to PyPI
on:
  release:
    types: [published]

# Cancel if a newer run is started
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  build-n-publish:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
        name: Check out source-code repository

      - name: Set up Python 3.12
        uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
        with:
          python-version: "3.13"

      - name: Install python dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          pip install .

      - name: Build the distribution
        run: python setup.py sdist bdist_wheel

      - name: Publish dist to PyPI
        if: github.repository == 'nf-core/tools'
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          password: ${{ secrets.pypi_password }}
