on:
  push:
    tags:
      - 'v*'

name: Create Release and Upload Release Asset

jobs:
  build:
    name: Create Release and Upload Release Asset
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      
      - name: Setup PHP with extensions
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
          extensions: json
          ini-values: memory_limit=-1
          tools: composer

      - name: Install dependencies
        run: composer install --prefer-dist --no-interaction --no-progress --ansi
      
      - name: Download box.phar
        run: wget -O box.phar https://github.com/humbug/box/releases/download/4.2.0/box.phar
      
      - name: Compile project
        run: php ./box.phar compile

      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          name: Release ${{ github.ref_name }}
          body: ''
          draft: false
          prerelease: false
          files: schema.phar
