From cae96765cb8187698910b7fccf82a3f680f7cefa Mon Sep 17 00:00:00 2001 From: Daun Chung <62877191+daunchung@users.noreply.github.com> Date: Fri, 27 May 2022 15:42:01 +0100 Subject: [PATCH] flatpack workflow to build flatpak installer (#7177) * flatpack workflow to build flatpak installer * rename flatpak build name * changing job-build-flatpak, disabling other job-tests meanwhile * update apt before attempting to install flatpak * changing install command * adding logs for installing flatpak * running installation as root * running installation as root - for each command * attempting to use github action to build flatpak * fix typo on name * typo in image * adding privilege option and fixing manifest path * changing manifest-path * uploading bundle to artifact * changing synergy.desktop for flatpak build * adding versioning to flatpak bundle and upload to bin storage on release * version info fix * running build_version as root * adding __w to safe directory * adding git config safe directory command to builder * testing which part of version info is breaking * falling back to local build of flatpak * running only the normal synergy * investigating build_version.py * investigating build_version.py 2 * investigating build_version.py 3 * checking if raspberry pi build is working correctly * get subprocess error * printing subprocess error * disabling try catch in version * running git rev-list --tags command * running git rev-list --tags command * disabling other tests * trying to run extra step in gitaction * trying to remove extra step in gitaction * fixing issues with subprocess * try to run git rev-list * test * ignore versioning * run original flatpak * testing various build options * attempting to run flatpak through raspberry * raspberry flatpak installation 1 * fixing tabs in flatpak build * trying apt over apt-get * removing sudo from build process * removing apt update * trying to build without versioning * testing build without publish * testing * adding fetch-depth in checkout * checking out with v3 * getting flatpak to run without github action * using ubuntu20.04 container * attempting to add __w into safe directory * adding dependencies installation * remove sudo from installing dependencies * removing all sudo commands from flatpak install * moving all the apt-get installs in dependencies job * add yes response to flatpak platform & sdk install * proper install command for flatpak builder * flathub input yes to flatpak builder install * check if flatpak folder exist * adding flatpak using apt-get * add privilege option in docker * removing flatpak finalize build / remove com.symless.Synergy * listing flatpak dir * testing to publish flatpak * checking the directory for flatpak file * correcting the path for scp action * attempting to create a specific file in scp * flatpak workflow cleanup * cleaning up * adding changelog info and changing flatpak patch files location * fedora add safe directory * creating business/enterprise YAML to replace based on env var * build test * disabling tests * fixing YAML struct * disabling replace action to see if its causing issue * changing cp command without backslash * checking if condition syntax * uncommenting error at build_version * fixing file location * cleaning up actions * changing workkflow to use .yml file without copying * finalizing git action * Remove git safe directory * Add final line to missing files * Move safe directory workaround * Minor cleanup for flatpak files Co-authored-by: Daun Chung Co-authored-by: Kyle Bloom --- .github/workflows/job-build-flatpak.yaml | 98 ++++++++++++++++++++++++ .gitignore | 5 ++ CI/build_version.py | 8 +- ChangeLog | 1 + flatpak/flatpak-desktop.patch | 14 ++++ flatpak/synergy-business.yml | 44 +++++++++++ flatpak/synergy-enterprise.yml | 44 +++++++++++ flatpak/synergy.yml | 41 ++++++++++ 8 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/job-build-flatpak.yaml create mode 100644 flatpak/flatpak-desktop.patch create mode 100644 flatpak/synergy-business.yml create mode 100644 flatpak/synergy-enterprise.yml create mode 100644 flatpak/synergy.yml diff --git a/.github/workflows/job-build-flatpak.yaml b/.github/workflows/job-build-flatpak.yaml new file mode 100644 index 000000000..833533e85 --- /dev/null +++ b/.github/workflows/job-build-flatpak.yaml @@ -0,0 +1,98 @@ +name: Ubuntu-flatpak + +on: + release: + types: [created] + +jobs: + build-flatpak-bundle: + name: ubuntu-flatpak + runs-on: ubuntu-latest + container: + image: symless/synergy-core:ubuntu20.04 + options: --privileged + strategy: + matrix: + name: [synergy, synergy-enterprise, synergy-business] + include: + - name: synergy + remote_folder: v1-core-standard + - name: synergy-enterprise + remote_folder: v1-core-enterprise + - name: synergy-business + remote_folder: v1-core-business + env: + GIT_COMMIT: ${{ github.sha }} + SYNERGY_ENTERPRISE: ${{ matrix.enterprise }} + SYNERGY_BUSINESS: ${{ matrix.business }} + + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + fetch-depth: "0" + + - name: Install Dependencies + run: | + apt-get update + apt-get install -y \ + cmake python3 g++ \ + libssl-dev libx11-dev xorg-dev qtbase5-dev \ + libglib2.0-dev libgdk-pixbuf2.0-dev libnotify-dev \ + flatpak flatpak-builder + + - name: Work around https://github.com/actions/checkout/issues/766 + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + - name: Version Info + id: version + run: | + python3 CI/build_version.py + mkdir -p version-info && cd version-info && cmake .. && cd .. + . ./version-info/version + rm -rf version-info + SYNERGY_VERSION="$SYNERGY_VERSION_MAJOR.$SYNERGY_VERSION_MINOR.$SYNERGY_VERSION_PATCH" + SYNERGY_REVISION=$(git rev-parse --short=8 HEAD) + SYNERGY_DEB_VERSION="${SYNERGY_VERSION}.${SYNERGY_VERSION_STAGE}.${SYNERGY_REVISION}" + echo "::set-output name=SYNERGY_VERSION_MAJOR::${SYNERGY_VERSION_MAJOR}" + echo "::set-output name=SYNERGY_VERSION_MINOR::${SYNERGY_VERSION_MINOR}" + echo "::set-output name=SYNERGY_VERSION_PATCH::${SYNERGY_VERSION_PATCH}" + echo "::set-output name=SYNERGY_VERSION_STAGE::${SYNERGY_VERSION_STAGE}" + echo "::set-output name=SYNERGY_VERSION_BUILD::${SYNERGY_VERSION_BUILD}" + echo "::set-output name=SYNERGY_VERSION::${SYNERGY_VERSION}" + echo "::set-output name=SYNERGY_REVISION::${SYNERGY_REVISION}" + echo "::set-output name=SYNERGY_DEB_VERSION::${SYNERGY_DEB_VERSION}" + echo "::set-output name=SYNERGY_REMOTE_FOLDER::${{ matrix.remote_folder }}/${SYNERGY_VERSION}/${SYNERGY_VERSION_STAGE}/b${SYNERGY_VERSION_BUILD}-${SYNERGY_REVISION}" + echo "::set-output name=SYNERGY_PACKAGE_NAME::${{ matrix.name }}" + + - name: Install flatpak + run: | + flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + flatpak install -y org.kde.Platform//5.15-21.08 + flatpak install -y org.kde.Sdk//5.15-21.08 + + - name: Build + run: | + cd flatpak + flatpak-builder build ${{ matrix.name }}.yml --disable-cache --force-clean + flatpak build-export export build + flatpak build-bundle export ${{ matrix.name }}.flatpak com.symless.Synergy master --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo + + - name: Upload Artifact + uses: actions/upload-artifact@v2 + if: "github.event_name == 'pull_request'" + with: + name: Bundle + path: flatpak/${{ matrix.name }}.flatpak + retention-days: 1 + + - name: Send package to Binary Storage + if: "github.event_name == 'pull_request'" + uses: garygrossgarten/github-action-scp@v0.7.3 + with: + local: flatpak/${{ matrix.name }}.flatpak + remote: ${{ secrets.BINARIES_SSH_DIR }}/${{ steps.version.outputs.SYNERGY_REMOTE_FOLDER }}/${{ matrix.name }}.flatpak + host: ${{ secrets.BINARIES_SSH_HOST }} + username: ${{ secrets.BINARIES_SSH_USER }} + privateKey: ${{ secrets.BINARIES_SSH_KEY }} diff --git a/.gitignore b/.gitignore index bbcf39592..3cfd0dd6c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,8 @@ src/setup/win32/synergy.suo /CMakeLists.txt.* /doxygen/ /deps +flatpak/.flatpak-builder +flatpak/build +flatpak/export +flatpak/synergy.desktop +flatpak/*.flatpak diff --git a/CI/build_version.py b/CI/build_version.py index 65883e44a..d508bf7a2 100644 --- a/CI/build_version.py +++ b/CI/build_version.py @@ -91,9 +91,9 @@ def findVersion(versions, cmakeVersion): print('INFO: Version '+ str(gitVersion) + ' has been read from git') return gitVersion -def getVesionFromGit(cmakeVersion): +def getVersionFromGit(cmakeVersion): try: - taggedRevision = subprocess.check_output(('git rev-list --tags --max-count=100').split(), universal_newlines=True) + taggedRevision = subprocess.check_output(('git rev-list --tags --max-count=100').split(), universal_newlines=True) cmd = ('git describe --tags ' + taggedRevision).split() versions = subprocess.check_output(cmd, universal_newlines=True).split() return findVersion(versions, cmakeVersion) @@ -132,6 +132,6 @@ def getVersionFromFile(): if __name__ == '__main__': cmakeVersion = getVersionFromFile() - gitVersion = getVesionFromGit(cmakeVersion) + gitVersion = getVersionFromGit(cmakeVersion) updateVersionFile(gitVersion.build.number) - print('INFO: Build number is: <' + str(gitVersion) + '>') \ No newline at end of file + print('INFO: Build number is: <' + str(gitVersion) + '>') diff --git a/ChangeLog b/ChangeLog index b51dee78c..b2f271d09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Bug fixes: - #7179 Disable drag and drop by default Github Actions: +- #7177 Create workflow for flatpak build support - #7148 Fix unstable build for windows core - #7156 Change binary storage server - #7161 Use brew bundle to install dependencies diff --git a/flatpak/flatpak-desktop.patch b/flatpak/flatpak-desktop.patch new file mode 100644 index 000000000..1fca84738 --- /dev/null +++ b/flatpak/flatpak-desktop.patch @@ -0,0 +1,14 @@ +diff --git a/res/synergy.desktop b/res/synergy.desktop +index fa987bdf..9513dbf3 100644 +--- a/res/synergy.desktop ++++ b/res/synergy.desktop +@@ -3,8 +3,7 @@ Type=Application + Version=1.0 + Name=Synergy + Comment=Keyboard and mouse sharing solution +-Path=/usr/bin +-Exec=/usr/bin/synergy ++Exec= + Icon=synergy + Terminal=false + Categories=Utility; diff --git a/flatpak/synergy-business.yml b/flatpak/synergy-business.yml new file mode 100644 index 000000000..d76bcb1e1 --- /dev/null +++ b/flatpak/synergy-business.yml @@ -0,0 +1,44 @@ +app-id: com.symless.Synergy +runtime: org.kde.Platform +runtime-version: "5.15-21.08" +sdk: org.kde.Sdk +rename-icon: synergy +rename-desktop-file: synergy.desktop +build-options: + env: + SYNERGY_BUSINESS: "1" +modules: + - name: openssl + buildsystem: simple + build-commands: + - "./config --prefix=/app" + - "make" + - "make install_sw" + sources: + - type: archive + url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1n.tar.gz + sha256: 6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e + - name: libnotify + buildsystem: meson + config-opts: + - "-Dman=false" + - "-Dgtk_doc=false" + sources: + - type: git + url: https://gitlab.gnome.org/GNOME/libnotify.git + - name: synergy + buildsystem: cmake-ninja + config-opts: + - "-DCMAKE_BUILD_TYPE=Release" + sources: + - type: dir + path: ../ + - type: patch + path: flatpak-desktop.patch +command: synergy +finish-args: + - "--share=ipc" + - "--socket=x11" + - "--share=network" + - "--device=dri" + - "--talk-name=org.a11y.*" diff --git a/flatpak/synergy-enterprise.yml b/flatpak/synergy-enterprise.yml new file mode 100644 index 000000000..4c94840c1 --- /dev/null +++ b/flatpak/synergy-enterprise.yml @@ -0,0 +1,44 @@ +app-id: com.symless.Synergy +runtime: org.kde.Platform +runtime-version: "5.15-21.08" +sdk: org.kde.Sdk +rename-icon: synergy +rename-desktop-file: synergy.desktop +build-options: + env: + SYNERGY_ENTERPRISE: "1" +modules: + - name: openssl + buildsystem: simple + build-commands: + - "./config --prefix=/app" + - "make" + - "make install_sw" + sources: + - type: archive + url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1n.tar.gz + sha256: 6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e + - name: libnotify + buildsystem: meson + config-opts: + - "-Dman=false" + - "-Dgtk_doc=false" + sources: + - type: git + url: https://gitlab.gnome.org/GNOME/libnotify.git + - name: synergy + buildsystem: cmake-ninja + config-opts: + - "-DCMAKE_BUILD_TYPE=Release" + sources: + - type: dir + path: ../ + - type: patch + path: flatpak-desktop.patch +command: synergy +finish-args: + - "--share=ipc" + - "--socket=x11" + - "--share=network" + - "--device=dri" + - "--talk-name=org.a11y.*" diff --git a/flatpak/synergy.yml b/flatpak/synergy.yml new file mode 100644 index 000000000..32768f7bc --- /dev/null +++ b/flatpak/synergy.yml @@ -0,0 +1,41 @@ +app-id: com.symless.Synergy +runtime: org.kde.Platform +runtime-version: "5.15-21.08" +sdk: org.kde.Sdk +rename-icon: synergy +rename-desktop-file: synergy.desktop +modules: + - name: openssl + buildsystem: simple + build-commands: + - "./config --prefix=/app" + - "make" + - "make install_sw" + sources: + - type: archive + url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1n.tar.gz + sha256: 6b2d2440ced8c802aaa61475919f0870ec556694c466ebea460e35ea2b14839e + - name: libnotify + buildsystem: meson + config-opts: + - "-Dman=false" + - "-Dgtk_doc=false" + sources: + - type: git + url: https://gitlab.gnome.org/GNOME/libnotify.git + - name: synergy + buildsystem: cmake-ninja + config-opts: + - "-DCMAKE_BUILD_TYPE=Release" + sources: + - type: dir + path: ../ + - type: patch + path: flatpak-desktop.patch +command: synergy +finish-args: + - "--share=ipc" + - "--socket=x11" + - "--share=network" + - "--device=dri" + - "--talk-name=org.a11y.*"