srevinsaju/guiscrcpy

View on GitHub
.github/workflows/continuous.yml

Summary

Maintainability
Test Coverage

name: Continuous
on: 
  - push

jobs:
  Wheel:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - uses: actions/setup-python@v1
      with:
        python-version: 3.9

    - name: Build wheel
      run: |
        python -m pip install wheel poetry twine
        poetry build
        
    - name: Upload artifact
      uses: actions/upload-artifact@v1.0.0
      with:
        name: guiscrcpy-python
        path: dist/

    - name: Publish distribution 📦 to Test PyPI
      if: startsWith(github.ref, 'refs/tags/v')
      env:
        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
      run: twine upload --skip-existing dist/*

  AppImage:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        type: ['r', 'm']
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Fetch all tags
        run: git fetch --tags --force
      - name: Build
        run: |
          # force usage of PySide2 to prevent having surprises with pyinstaller.
          sed -i 's/qtpy/PySide2/g' **/*.py
          docker build -t guiscrcpy-appimage-build -f scripts/ci/pyappimage/Dockerfile .
          docker run --rm -v $(pwd):/usr/src guiscrcpy-appimage-build
          ls -al 

      - name: Create guiscrcpy
        if: matrix.type == 'm'
        run: |
          export GUISCRCPY_VERSION="$(git describe --tags --always --match 'v*.*').dev"
          export GUISCRCPY_GLIB_VERSION="glibc$(ldd --version | grep 'ldd ' | grep -o ').[0-9].[0-9][0-9]' | grep -o '[0-9].[0-9][0-9]')"
          export GUISCRCPY_MACHINE="$(uname -m)"
          export GUISCRCPY_TYPE="m"
          ./scripts/build-appimage.sh

      - name: Bundle scrcpy
        if: matrix.type == 'r'
        run: |
          export GUISCRCPY_VERSION="$(git describe --tags --always --match 'v*.*').dev"
          export GUISCRCPY_GLIB_VERSION="glibc$(ldd --version | grep 'ldd ' | grep -o ').[0-9].[0-9][0-9]' | grep -o '[0-9].[0-9][0-9]')"
          export GUISCRCPY_MACHINE="$(uname -m)"
          export GUISCRCPY_TYPE="r"
          ./scripts/build-appimage.sh

      - name: Install Destop Environment
        run: |
          echo "adapted from https://github.com/AppImage/appimage.github.io/blob/master/.travis.yml"
          sudo apt-get update
          sudo apt-get -qq -y install imagemagick libasound2-dev pulseaudio-utils alsa-utils alsa-oss libjack0 desktop-file-utils xmlstarlet xterm xvfb icewm x11-utils x11-apps netpbm xdotool libgl1-mesa-dri libgl1-mesa-dev mesa-utils libosmesa6 libsdl1.2-dev fonts-wqy-microhei libfile-mimeinfo-perl libx11-xcb1 libxcb-xkb1 libxcb-* libxcb-render-util0 libxkbcommon-x11-0 libxkbcommon0 > /dev/null # appstream # TODO: Cache me!
          mkdir $HOME/.icewm/
          echo "ShowTaskBar = 0" > $HOME/.icewm/preferences
          echo "TaskBarAutoHide = 1" > $HOME/.icewm/preferences
          echo "TaskBarShowWorkspaces = 0" > $HOME/.icewm/preferences
          echo "TaskBarShowAllWindows = 0" > $HOME/.icewm/preferences
          echo "TaskBarShowClock = 0" > $HOME/.icewm/preferences
          echo "TaskBarShowMailboxStatus = 0" > $HOME/.icewm/preferences
          echo "TaskBarShowCPUStatus = 0" > $HOME/.icewm/preferences
          echo "TaskBarShowWindowListMenu = 0" > $HOME/.icewm/preferences

      - name: Run headless test
        if: matrix.type == 'r'
        run: |
          export LC_ALL=C.UTF-8
          export LANG=C.UTF-8
          export APPIMAGE_EXTRACT_AND_RUN=1
          echo "echo Dummy scrcpy" | sudo tee -a /usr/bin/scrcpy
          sudo chmod +x /usr/bin/scrcpy
          /usr/bin/xvfb-run --auto-servernum ./scripts/display-ci.sh "$(realpath _build/*.AppImage)"

      - name: Upload artifact
        uses: actions/upload-artifact@v1.0.0
        with:
          name: guiscrcpy-${{ matrix.type }}-continuous-x86_64.AppImage
          path: '_build'


  Windows:
    name: Windows
    runs-on: windows-latest
    strategy: 
      matrix:
        arch: ['x64', 'x86']
        qt: ['PyQt5', 'PySide2']
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Setup Python
        uses: actions/setup-python@v1
        with:
          python-version: '3.9'
          architecture: ${{ matrix.arch }}

      - name: Install dependencies
        shell: bash
        run: |
          python.exe -m pip install --upgrade pip wheel --user
          pip3 install --upgrade --user poetry PyInstaller ${{ matrix.qt }}
          poetry install -E ${{ matrix.qt }}
          poetry build
          pip3 install dist/*.whl

      - name: Create .exe
        run: |
          echo "from guiscrcpy.cli import cli; cli()" > entry.py
          python -m PyInstaller -n guiscrcpy-${{ matrix.qt }}-${{ matrix.arch }} .\entry.py --onefile -i guiscrcpy\ui\icons\guiscrcpy_logo_SRj_icon.ico --hidden-import pywin32

      - name: Upload artifact
        uses: actions/upload-artifact@v1.0.0
        with:
          # Artifact name
          name: guiscrcpy-${{ matrix.qt }}-${{ matrix.arch }}-continuous.exe
          # Directory containing files to upload
          path: dist


  MacOS:
    name: MacOS
    runs-on: macos-latest
    strategy: 
      matrix:
        arch: ['x64']
        qt: ['PySide2']
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Setup Python
        uses: actions/setup-python@v1
        with:
          python-version: '3.9'
          architecture: ${{ matrix.arch }}


      - name: Install dependencies
        run: |
          pip3 install --upgrade pip wheel
          pip3 install --upgrade poetry PyInstaller ${{ matrix.qt }}
          poetry build
          pip3 install dist/*.whl
          
      - name: Create .exe
        run: |
          echo "from guiscrcpy.cli import cli; cli()" > entry.py
          python -m PyInstaller -n guiscrcpy-${{ matrix.qt }}-${{ matrix.arch }} ./entry.py --onefile -i guiscrcpy/ui/icons/guiscrcpy_logo_SRj_icon.ico --osx-bundle-identifier 'io.github.srevinsaju.guiscrcpy' --windowed

      - name: Upload artifact
        uses: actions/upload-artifact@v1.0.0
        with:
          # Artifact name
          name: guiscrcpy-${{ matrix.qt }}-${{ matrix.arch }}-continuous.app
          # Directory containing files to upload
          path: dist


  Release:
    needs: [Windows, AppImage, Wheel, MacOS]
    runs-on: ubuntu-latest

    steps:
    - uses: actions/download-artifact@v2

    - name: Create release and upload artifacts
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        CHANGELOG_TYPE: conventional
      run: |
        ls -alHR
        export APPIMAGE_EXTRACT_AND_RUN=1
        wget -q https://github.com/srevinsaju/pyuploadtool/releases/download/continuous/pyuploadtool-x86_64.AppImage && chmod +x pyuploadtool-x86_64.AppImage
        ./pyuploadtool-x86_64.AppImage \
          guiscrcpy-PyQt5-x64-continuous.exe/guiscrcpy-PyQt5-x64.exe \
          guiscrcpy-PyQt5-x86-continuous.exe/guiscrcpy-PyQt5-x86.exe \
          guiscrcpy-PySide2-x64-continuous.app/guiscrcpy-PySide2-x64 \
          guiscrcpy-PySide2-x64-continuous.exe/guiscrcpy-PySide2-x64.exe \
          guiscrcpy-PySide2-x86-continuous.exe/guiscrcpy-PySide2-x86.exe \
          guiscrcpy-m-continuous-x86_64.AppImage/guiscrcpy*x86_64.AppImage \
          guiscrcpy-python/guiscrcpy*.* \
          guiscrcpy-r-continuous-x86_64.AppImage/guiscrcpy*.AppImage