From 12327bbaf82c96846e93dad0111594db05c98a73 Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Fri, 1 Oct 2021 08:43:22 +0300 Subject: [PATCH 1/3] ci: add build support for snaps --- .github/workflows/continuous.yml | 16 ++++++++++++ snap/snapcraft.yaml | 42 +++++++++----------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 2c5c9cb6..f3e68601 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -4,6 +4,22 @@ on: - push jobs: + Snap: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install snapcraft + run: | + sudo snap install --classic snapcraft + snapcraft --destructive-mode + + - name: Publish to Snap Store + run: | + echo "${{ secrets.SNAP_DEPLOY_TOKEN }}" > token.txt + # if: github.ref == 'refs/heads/master' + snapcraft upload --release=edge *.snap + Wheel: runs-on: ubuntu-latest steps: diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 19fb5da7..23f3f366 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -7,7 +7,7 @@ description: | grade: stable confinement: strict -base: core18 +base: core20 architectures: - build-on: amd64 @@ -53,40 +53,20 @@ parts: stage-snaps: - classic-launch - # Remote part for support of various desktop technologies - # Refer: https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml - desktop-qt5: - build-packages: - - build-essential - - qtbase5-dev - - dpkg-dev - make-parameters: - - FLAVOR=qt5 - plugin: make - source: https://github.com/ubuntu/snapcraft-desktop-helpers.git - source-subdir: qt - stage-packages: - - libxkbcommon0 - - ttf-ubuntu-font-family - - dmz-cursor-theme - - light-themes - - adwaita-icon-theme - - gnome-themes-standard - - shared-mime-info - - libqt5gui5 - - libgdk-pixbuf2.0-0 - - libqt5svg5 - - try: - - appmenu-qt5 - - locales-all - - xdg-user-dirs - - fcitx-frontend-qt5 - guiscrcpy: stage-snaps: - scrcpy - after: [desktop-qt5, classic-launch, debian-multiarch-triplet-provider-launch] + stage-packages: + - freeglut3 + after: [classic-launch, debian-multiarch-triplet-provider-launch] # See 'snapcraft plugins' + build-packages: + - python3-build + override-build: | + python -m build . + tar -xvf dist/*.tar.gz setup.py + rm -rf dist + snapcraftctl build plugin: python python-version: python3 source: . From f33ab3efc01afc42b9dee566ead690a77837fd73 Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Sat, 6 Nov 2021 09:23:48 +0300 Subject: [PATCH 2/3] ci: do not provide python-version param for core20 base image --- snap/snapcraft.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 23f3f366..ffb66351 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -68,7 +68,6 @@ parts: rm -rf dist snapcraftctl build plugin: python - python-version: python3 source: . plugs: From 5c76999bfcb08a272955d4c27c5d825da0861380 Mon Sep 17 00:00:00 2001 From: Srevin Saju Date: Sat, 6 Nov 2021 09:25:24 +0300 Subject: [PATCH 3/3] fix: install 'build' with pip --- .github/workflows/continuous.yml | 9 ++++++++ snap/snapcraft.yaml | 39 ++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index 0cddc4d1..de7ff1fb 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -14,9 +14,18 @@ jobs: sudo snap install --classic snapcraft snapcraft --destructive-mode + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: guiscrcpy-snap + path: 'guiscrcpy_*.snap' + + - name: Publish to Snap Store run: | echo "${{ secrets.SNAP_DEPLOY_TOKEN }}" > token.txt + mkdir -p ~/.snapcraft + cat token.txt | base64 --decode --ignore-garbage > ~/.snapcraft/snapcraft.cfg # if: github.ref == 'refs/heads/master' snapcraft upload --release=edge *.snap diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index ffb66351..dd787645 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -37,9 +37,7 @@ apps: command-chain: &command-chain-common - bin/debian-multiarch-triplet-provider-launch - bin/classic-launch - - bin/desktop-launch - bin/guiscrcpy - desktop: share/applications/guiscrcpy.desktop parts: @@ -61,12 +59,39 @@ parts: after: [classic-launch, debian-multiarch-triplet-provider-launch] # See 'snapcraft plugins' build-packages: - - python3-build + - python3-pip override-build: | - python -m build . - tar -xvf dist/*.tar.gz setup.py - rm -rf dist - snapcraftctl build + python -m venv $SNAPCRAFT_PART_INSTALL + source $SNAPCRAFT_PART_INSTALL/bin/activate + pip install poetry + python -m poetry install -E PySide2 --no-dev + ls -al $SNAPCRAFT_PART_INSTALL + find "${SNAPCRAFT_PART_INSTALL}" -type f -executable -print0 | xargs -0 \ + sed -i "1 s|^#\\!${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}.*$|#\\!/usr/bin/env ${SNAPCRAFT_PYTHON_INTERPRETER}|" + + determine_link_target() { + opts_state="$(set +o +x | grep xtrace)" + interp_dir="$(dirname "${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}")" + # Determine python based on PATH, then resolve it, e.g: + # (1) /home/ubuntu/.venv/snapcraft/bin/python3 -> /usr/bin/python3.8 + # (2) /usr/bin/python3 -> /usr/bin/python3.8 + # (3) /root/stage/python3 -> /root/stage/python3.8 + # (4) /root/parts//install/usr/bin/python3 -> /root/parts//install/usr/bin/python3.8 + python_path="$(which "${SNAPCRAFT_PYTHON_INTERPRETER}")" + python_path="$(readlink -e "${python_path}")" + for dir in "${SNAPCRAFT_PART_INSTALL}" "${SNAPCRAFT_STAGE}"; do + if echo "${python_path}" | grep -q "${dir}"; then + python_path="$(realpath --strip --relative-to="${interp_dir}" \\ + "${python_path}")" + break + fi + done + echo "${python_path}" + eval "${opts_state}" + } + python_path="$(determine_link_target)" + ln -sf "${python_path}" "${SNAPCRAFT_PYTHON_VENV_INTERP_PATH}" + plugin: python source: .