name: MLGO Packaging CI

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  BuildAndPublich:
    runs-on: ubuntu-latest
    name: Build and Publish Package
    steps:
      - uses: actions/checkout@v3
        name: Checkout repository
      - uses: actions/setup-python@v4
        name: Setup Python
        with:
          python-version: '3.10'
          cache: 'pip'
      - run: pip3 install build==0.10.0 setuptools==68.0.00 twine==4.0.2
        name: Install Packaging Dependencies
        # TODO(boomanaiden154): Switch this install step over to using pipenv
        # once regenerating the lockfile has been fixed.
      - run: python3 -m build
        name: Build package
      - run: twine upload dist/*
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}}
        name: Publish the package
        if: ${{github.repository_owner == 'google' && github.ref_name == 'main'}}
