name: Trigger upload binaries

on:
  workflow_dispatch:

jobs:
  Windows:
    name: Build for Windows
    runs-on: windows-latest
    strategy:
      matrix:
        arch: [x86_64]
        video: [DShow]
        include:
          - arch: x86_64
            msystem: MINGW64
            grep: x86-64
          - video: DShow
            extra: --with-directshow
    defaults:
      run:
        shell: msys2 {0}

    env:
      CPPFLAGS: -D__USE_MINGW_ANSI_STDIO=1

    steps:
    - name: install cli
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
         choco install gh
         gh release list

    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{ matrix.msystem }}
        update: false
        install: >-
          mingw-w64-${{ matrix.arch }}-gcc
          mingw-w64-${{ matrix.arch }}-iconv
          mingw-w64-${{ matrix.arch }}-imagemagick
          mingw-w64-${{ matrix.arch }}-python
          base-devel git xmlto zip
          autoconf libtool automake gettext make autoconf-archive pkg-config

    - uses: actions/checkout@v2

    - name: configure
      shell: msys2 {0}
      run: |
        autoreconf -vfi
        ./configure --enable-pthread --disable-dependency-tracking ${{ matrix.extra }}

    - name: build
      shell: msys2 {0}
      run:
        make
    - name: generating zip
      shell: msys2 {0}
      run: |
        DESTDIR=${PWD}/win_${{ matrix.arch }}-${{ matrix.video }} make install
        (cd ${PWD}/win_${{ matrix.arch }}-${{ matrix.video }}; zip -r ../zbar-win_${{ matrix.arch }}-${{ matrix.video }}.zip .)

