name: release

on:
  release:
    types: [published]

jobs:
  deploy:
    name: Upload release to PyPI
    runs-on: ubuntu-latest
    environment:
      name: release
      url: https://pypi.org/project/megatron-energon
    permissions:
      id-token: write  # This permission is mandatory for trusted publishing
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v5
  
      - name: Install just
        uses: extractions/setup-just@v3
  
      - name: Install dependencies
        run: |
          just dev-sync

      - name: Build package
        run: |
          just build

      - name: Publish package
        uses: pypa/gh-action-pypi-publish@release/v1
