name: Build and Release Zip Archives of Web MiniDisc 💽
on:
  push:
    tags:
      - '*'
jobs:
  create-zip-release:
    runs-on: ubuntu-20.04
    steps:
      - name: Install system dependencies 🏗
        run: |
          sudo apt-get update
          sudo apt-get -y install build-essential libudev-dev libusb-1.0-0-dev

      - name: Checkout 🛎️
        uses: actions/checkout@v2.3.1

      - name: Build no-ga Release 🔧
        run: |
          npm install
          npm run build
        env:
          CI: false # Do not treat warnings as errors
          PUBLIC_URL: ./
          REACT_APP_NO_GA_RELEASE: true # disables service workers and GA

      - name: Create Archive 📦
        uses: thedoctor0/zip-release@master
        with:
          type: 'zip'
          filename: 'release-no-ga.zip'
          directory: 'build'
          exclusions: '.DS_Store service-worker.js final-service-worker.js extra-service-worker.js'

      - name: Copy Release Archive
        run: mv build/release-no-ga.zip ./

      - name: Build Release 🔧
        run: npm run build
        env:
          CI: false # Do not treat warnings as errors
          PUBLIC_URL: ./

      - name: Create Archive 📦
        uses: thedoctor0/zip-release@master
        with:
          type: 'zip'
          filename: 'release.zip'
          directory: 'build'
          exclusions: '.DS_Store'

      - name: Copy no-g Release Archive
        run: mv build/release.zip ./

      - uses: ncipollo/release-action@v1
        with:
          artifacts: "release.zip,release-no-ga.zip"
          token: ${{ secrets.GITHUB_TOKEN }}
          draft: true
          replacesArtifacts: true
