private-dreamnet/dreampower

View on GitHub
.github/workflows/build-release.yml

Summary

Maintainability
Test Coverage
name: Build Release

on:
  push:
    paths:
      - src/**
      - .github/workflows/**
    tags:
      - v*

jobs:
  build:
    name: ${{ matrix.platform }} (${{ matrix.device }})
    runs-on: ${{ matrix.os }}

    # Strategy
    # or a.k.a variables for multiple platforms
    # https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstrategy
    strategy:
      fail-fast: true
      matrix:
        os:
          - windows-latest
          - ubuntu-latest
          - macOS-latest
        device:
          - any
          - cpuonly

        include:
          - os: ubuntu-latest # Ubuntu
            platform: ubuntu
            python: python3
          - os: windows-latest # Windows
            platform: windows
            python: python
          - os: macOS-latest # macOS
            platform: macos
            python: python3

        exclude:
          - os: macOS-latest
            device: any

    steps:
      - uses: actions/checkout@v1

      - name: Install Python 3.7
        uses: actions/setup-python@v2
        with:
          python-version: 3.7
          architecture: x64

      - name: Install Node.js 12
        uses: actions/setup-node@v1
        with:
          node-version: 12.x

      - name: Install Yarn
        run: npm install -g yarn

      - name: Install Dependencies (NodeJS)
        working-directory: src/scripts
        run: yarn install --network-timeout 1000000

      - name: Install Dependencies (Python)
        working-directory: src
        run: |
          ${{ matrix.python }} -m pip install -r requirements.txt
          ${{ matrix.python }} -m pip install pyinstaller

      - name: Install Dependencies (CUDA)
        working-directory: src
        if: matrix.device == 'any' && matrix.platform != 'macos'
        run: ${{ matrix.python }} -m pip install -r requirements-gpu.txt -f https://download.pytorch.org/whl/torch_stable.html --user

      - name: Install Dependencies (CPU)
        working-directory: src
        if: matrix.device == 'cpuonly' && matrix.platform != 'macos'
        run: ${{ matrix.python }} -m pip install -r requirements-cpu.txt -f https://download.pytorch.org/whl/torch_stable.html --user

      - name: Install Dependencies (macOS)
        working-directory: src
        if: matrix.platform == 'macos'
        run: |
          brew install p7zip libomp
          ${{ matrix.python }} -m pip install -r requirements-gpu.txt --user

      - name: Build
        working-directory: src/scripts
        run: ${{ matrix.python }} build.py --debug

      - uses: actions/upload-artifact@v2
        with:
          name: dreampower-${{ matrix.platform }}-${{ matrix.device }}
          path: dist/dreampower/

      - name: Deploy
        working-directory: src/scripts
        continue-on-error: true
        timeout-minutes: 20
        env:
          GITHUB_SHA: ${{ github.sha }}
          GITHUB_REF: ${{ github.ref }}
          BUILD_PLATFORM: ${{ matrix.platform }}
          BUILD_DEVICE: ${{ matrix.device }}
          DEPLOY_ENCRYPT_KEY: ${{ secrets.DEPLOY_ENCRYPT_KEY }}
          DEPLOY_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DEPLOY_GITHUB_OWNER: dreamnettech
          DEPLOY_TEKNIK_TOKEN: ${{ secrets.DEPLOY_TEKNIK_TOKEN }}
          DEPLOY_TEKNIK_OWNER: dreamnet
          DEPLOY_PINATA_KEY: ${{ secrets.DEPLOY_PINATA_KEY }}
          DEPLOY_PINATA_SECRET: ${{ secrets.DEPLOY_PINATA_SECRET }}
          DEPLOY_MEGA_EMAIL: ${{ secrets.DEPLOY_MEGA_EMAIL }}
          DEPLOY_MEGA_PASSWORD: ${{ secrets.DEPLOY_MEGA_PASSWORD }}
          DEPLOY_MEGA_FOLDER: "/Projects/DreamPower/Releases/"
        run: node deploy.js