name: "Windows Release Build"

on:
  release:
    types: [ published ]

jobs:
  windows-release-build:
    strategy:
      fail-fast: false
      matrix:
        # Note: keep this in sync with the Windows matrix in tests.yml
        php: [ "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" ]
        arch: [ x64, x86 ]
        ts: [ ts, nts ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Download DLL and PDB files
        uses: dawidd6/action-download-artifact@v2
        with:
          workflow: tests.yml
          workflow_conclusion: success
          commit: ${{ github.sha }}
          # Note: keep this in sync with the uploaded artifact name in tests.yml
          name: php_mongodb-${{ github.sha }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}

      - name: Create and attach release archive
        run: |
          ARCHIVE=php_mongodb-${{ github.ref_name }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.arch }}.zip
          zip $ARCHIVE php_mongodb.dll php_mongodb.pdb CREDITS CONTRIBUTING.md LICENSE README.md THIRD_PARTY_NOTICES
          hub release edit -a $ARCHIVE -m "" $GITHUB_REF_NAME
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
