From 49984b60057fee4331d09accc6810e132c71b367 Mon Sep 17 00:00:00 2001 From: aditya24raj <57558529+aditya24raj@users.noreply.github.com> Date: Thu, 10 Mar 2022 13:52:45 +0530 Subject: [PATCH 1/4] build AppImage at push & pull-requests on master creates AppImage at push & pull-request on master branch and uploads it as artifact. Update create_appimage.sh --- .github/scripts/create_appimage.sh | 72 ++++++++++++++++++++++++++++ .github/scripts/setup_scrcpy.sh | 23 +++++++++ .github/workflows/build-appimage.yml | 48 +++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 .github/scripts/create_appimage.sh create mode 100644 .github/scripts/setup_scrcpy.sh create mode 100644 .github/workflows/build-appimage.yml 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 From fbf515e0adc4121b984d3f1efe1f7638ed29deef Mon Sep 17 00:00:00 2001 From: aditya24raj <57558529+aditya24raj@users.noreply.github.com> Date: Wed, 8 Jun 2022 09:41:43 +0530 Subject: [PATCH 2/4] get latest scrcpy-server automatically --- .github/scripts/setup_scrcpy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/setup_scrcpy.sh b/.github/scripts/setup_scrcpy.sh index bd090295..2893de71 100644 --- a/.github/scripts/setup_scrcpy.sh +++ b/.github/scripts/setup_scrcpy.sh @@ -10,7 +10,8 @@ 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 \ +latest_tag=$(git describe --tags --abbrev=0) +wget https://github.com/Genymobile/scrcpy/releases/download/$latest_tag/scrcpy-server-$latest_tag \ -O scrcpy-server meson x --buildtype=release --strip -Db_lto=true \ From f7ddc8f79b2add2cd5ad92c0def966be2de13723 Mon Sep 17 00:00:00 2001 From: aditya24raj <57558529+aditya24raj@users.noreply.github.com> Date: Wed, 8 Jun 2022 09:46:35 +0530 Subject: [PATCH 3/4] package all libs and executables in single command packaging each lib and executable seperately takes ~30 mins, while packing all at once takes only ~1-2 mins. --- .github/scripts/create_appimage.sh | 34 +++++++----------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/.github/scripts/create_appimage.sh b/.github/scripts/create_appimage.sh index e20b9c7e..468708f0 100644 --- a/.github/scripts/create_appimage.sh +++ b/.github/scripts/create_appimage.sh @@ -40,33 +40,15 @@ 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 +./linuxdeploy-x86_64.AppImage --appdir scrcpy_dir -e scrcpy/x/app/scrcpy -i scrcpy/app/data/scrcpy.png --create-desktop-file --custom-apprun=AppRun \ +-e /usr/bin/ffmpeg -e /usr/bin/ffplay -e /usr/bin/ffprobe -e /usr/bin/qt-faststart \ +-l /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.10.0 -l /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 \ +-l /usr/lib/android-sdk/platform-tools/adb -e /usr/bin/adb \ +-l /lib/x86_64-linux-gnu/libusb-1.0.so.0.2.0 -l /lib/x86_64-linux-gnu/libusb-1.0.so.0 \ +-l /lib/x86_64-linux-gnu/libpango-1.0.so.0 -l /lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 -l /lib/x86_64-linux-gnu/libgobject-2.0.so.0 \ +--output appimage echo "Done" + From c81aaf119e11e75d620735c731cd7acf99861199 Mon Sep 17 00:00:00 2001 From: aditya24raj <57558529+aditya24raj@users.noreply.github.com> Date: Wed, 8 Jun 2022 09:53:02 +0530 Subject: [PATCH 4/4] add tag to AppImage artifact Update build-appimage.yml Update setup_scrcpy.sh Update build-appimage.yml Update setup_scrcpy.sh Update build-appimage.yml Update setup_scrcpy.sh Update build-appimage.yml Update build-appimage.yml Update build-appimage.yml Update build-appimage.yml Update build-appimage.yml Update build-appimage.yml add release tag to appimage name Update build-appimage.yml Update create_appimage.sh Update build-appimage.yml Update build-appimage.yml --- .github/scripts/setup_scrcpy.sh | 2 ++ .github/workflows/build-appimage.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/scripts/setup_scrcpy.sh b/.github/scripts/setup_scrcpy.sh index 2893de71..e3831a52 100644 --- a/.github/scripts/setup_scrcpy.sh +++ b/.github/scripts/setup_scrcpy.sh @@ -11,6 +11,8 @@ git clone https://github.com/Genymobile/scrcpy cd scrcpy latest_tag=$(git describe --tags --abbrev=0) +echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV # will be used to upload artifact with tag + wget https://github.com/Genymobile/scrcpy/releases/download/$latest_tag/scrcpy-server-$latest_tag \ -O scrcpy-server diff --git a/.github/workflows/build-appimage.yml b/.github/workflows/build-appimage.yml index 98d3fb57..cc0a5cb8 100644 --- a/.github/workflows/build-appimage.yml +++ b/.github/workflows/build-appimage.yml @@ -43,6 +43,6 @@ jobs: - name: Upload output file uses: actions/upload-artifact@v3 with: - name: scrcpy-x86_64.AppImage + name: scrcpy-x86_64-${{ env.LATEST_TAG }}.AppImage path: ./scrcpy*.AppImage - \ No newline at end of file +