diff --git a/.github/scripts/create_appimage.sh b/.github/scripts/create_appimage.sh new file mode 100644 index 00000000..e20b9c7e --- /dev/null +++ b/.github/scripts/create_appimage.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +rm -rf scrcpy_dir +rm scrcpy*.AppImage +rm linuxdeploy-x86_64.AppImage + +trap "{ echo script failed; exit; }" ERR + +# download linuxdeploy.appimage +wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +chmod +x linuxdeploy-x86_64.AppImage + +# create AppRun +cat << EOF > AppRun +#!/bin/sh +SELF=\$(readlink -f "\$0") +HERE=\${SELF%/*} +export PATH="\${HERE}/usr/bin/:\${HERE}/usr/sbin/:\${HERE}/usr/games/:\${HERE}/bin/:\${HERE}/sbin/\${PATH:+:\$PATH}" +export LD_LIBRARY_PATH="\${HERE}/usr/lib/:\${HERE}/usr/lib/i386-linux-gnu/:\${HERE}/usr/lib/x86_64-linux-gnu/:\${HERE}/usr/lib32/:\${HERE}/usr/lib64/:\${HERE}/lib/:\${HERE}/lib/i386-linux-gnu/:\${HERE}/lib/x86_64-linux-gnu/:\${HERE}/lib32/:\${HERE}/lib64/\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}" +export PYTHONPATH="\${HERE}/usr/share/pyshared/\${PYTHONPATH:+:\$PYTHONPATH}" +export XDG_DATA_DIRS="\${HERE}/usr/share/\${XDG_DATA_DIRS:+:\$XDG_DATA_DIRS}" +export PERLLIB="\${HERE}/usr/share/perl5/:\${HERE}/usr/lib/perl5/\${PERLLIB:+:\$PERLLIB}" +export GSETTINGS_SCHEMA_DIR="\${HERE}/usr/share/glib-2.0/schemas/\${GSETTINGS_SCHEMA_DIR:+:\$GSETTINGS_SCHEMA_DIR}" +export QT_PLUGIN_PATH="\${HERE}/usr/lib/qt4/plugins/:\${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:\${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:\${HERE}/usr/lib32/qt4/plugins/:\${HERE}/usr/lib64/qt4/plugins/:\${HERE}/usr/lib/qt5/plugins/:\${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:\${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:\${HERE}/usr/lib32/qt5/plugins/:\${HERE}/usr/lib64/qt5/plugins/\${QT_PLUGIN_PATH:+:\$QT_PLUGIN_PATH}" + + +export ADB="\${HERE}/usr/bin/adb" +export SCRCPY_ICON_PATH="\${HERE}/scrcpy.png" +export SCRCPY_SERVER_PATH="\${HERE}/usr/share/scrcpy/scrcpy-server" + + +EXEC=\${HERE}/usr/bin/scrcpy +exec "\${EXEC}" "\$@" +EOF + +echo "making appdir" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir 1> /dev/null + +mkdir -p scrcpy_dir/usr/share/scrcpy/ 1> /dev/null +cp scrcpy/scrcpy-server scrcpy_dir/usr/share/scrcpy/scrcpy-server 1> /dev/null + + +echo "packaging ffmpeg" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e /usr/bin/ffmpeg 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e /usr/bin/ffplay 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e /usr/bin/ffprobe 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e /usr/bin/qt-faststart 1> /dev/null + +echo "packaging libSDL" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.10.0 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 1> /dev/null + +echo "packaging adb" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /usr/lib/android-sdk/platform-tools/adb 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e /usr/bin/adb 1> /dev/null + +echo "packaging libusb" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /lib/x86_64-linux-gnu/libusb-1.0.so.0.2.0 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /lib/x86_64-linux-gnu/libusb-1.0.so.0 1> /dev/null + +echo "packaging libs required at runtime" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /lib/x86_64-linux-gnu/libpango-1.0.so.0 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 1> /dev/null +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -l /lib/x86_64-linux-gnu/libgobject-2.0.so.0 1> /dev/null + +echo "packaging scrcpy" +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e scrcpy/x/app/scrcpy -i scrcpy/app/data/scrcpy.png \ +--create-desktop-file --custom-apprun=AppRun --output appimage 1> /dev/null + +echo "Done" + + diff --git a/.github/scripts/setup_scrcpy.sh b/.github/scripts/setup_scrcpy.sh new file mode 100644 index 00000000..bd090295 --- /dev/null +++ b/.github/scripts/setup_scrcpy.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +sudo apt update +sudo apt install ffmpeg libsdl2-2.0-0 adb libusb-1.0-0 -y +sudo apt install gcc git pkg-config meson ninja-build libsdl2-dev \ + libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \ + libusb-1.0-0-dev -y + +sudo rm -rf scrcpy +git clone https://github.com/Genymobile/scrcpy +cd scrcpy + +wget https://github.com/Genymobile/scrcpy/releases/download/v1.23/scrcpy-server-v1.23 \ +-O scrcpy-server + +meson x --buildtype=release --strip -Db_lto=true \ + -Dprebuilt_server=scrcpy-server +ninja -Cx + +# icon name should be same as binary name for appimage creation +cp app/data/icon.png app/data/scrcpy.png + +cd ../ diff --git a/.github/workflows/build-appimage.yml b/.github/workflows/build-appimage.yml new file mode 100644 index 00000000..98d3fb57 --- /dev/null +++ b/.github/workflows/build-appimage.yml @@ -0,0 +1,48 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # check out github repo, $GITHUB_WORKSPACE + - uses: actions/checkout@v3 + + # make our scripts executable + - run: chmod +x $GITHUB_WORKSPACE/.github/scripts/setup_scrcpy.sh + - run: chmod +x $GITHUB_WORKSPACE/.github/scripts/create_appimage.sh + + # install dependencies of scrcpy and builds scrcpy + - name: Run scrcpy setup script + run: $GITHUB_WORKSPACE/.github/scripts/setup_scrcpy.sh + shell: bash + + # bundle dependencies and scrcpy to create appimage + - name: Run create appimage script + run: $GITHUB_WORKSPACE/.github/scripts/create_appimage.sh + shell: bash + + # upload scrcpy appimage + - name: Upload output file + uses: actions/upload-artifact@v3 + with: + name: scrcpy-x86_64.AppImage + path: ./scrcpy*.AppImage + \ No newline at end of file