name: package
on: [push]
permissions:
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python:
          - "3.11"
          - "3.12"
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - name: Install dependencies
        run: |
          sudo apt-get install -y libicu-dev
          python -m pip install --upgrade pip wheel pyicu
          pip install -e ".[dev]"
      - name: Generate data file
        run: |
          make generate
      - name: Type checking
        run: |
          make typecheck
      - name: Test with pytest
        run: |
          make test
      - name: Build a distribution
        if: matrix.python == '3.12'
        run: |
          python3 -m build --wheel
      - name: Publish a Python distribution to PyPI
        if: matrix.python == '3.12' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          skip-existing: true
          verbose: true
