From affd253e211c06752ff9fb67b2fe25c7398ae91c Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 23 Aug 2023 08:46:11 +0800 Subject: [PATCH] feat: support AppImage (#3248) * feat: add build deb shell script * feat: update release.yml * chore: add flatpak readme * feat: support appimage builder * feat: support appimage builder * Update release.yml --- .github/workflows/release.yml | 31 ++------ .gitignore | 4 + .../linux/appflowy.desktop.temp | 8 -- .../flowy_icons/generate_flowy_icons.sh | 0 .../appimage/AppImageBuilder.yml | 76 +++++++++++++++++++ .../appimage/build_appimage.sh | 18 +++++ .../appimage/io.appflowy.AppFlowy.desktop | 0 .../linux_distribution/deb/AppFlowy.desktop | 10 +++ .../linux_distribution/deb/DEBIAN/control | 8 ++ .../linux_distribution/deb/DEBIAN/postinst | 8 ++ .../linux_distribution/deb/DEBIAN/postrm | 5 ++ .../scripts/linux_distribution/deb/README.md | 18 +++++ .../linux_distribution/deb/build_deb.sh | 42 ++++++++++ .../linux_distribution/flatpak/README.md | 1 + .../linux_distribution/packaging/appflowy.svg | 11 +++ .../io.appflowy.AppFlowy.launcher.desktop | 6 ++ .../io.appflowy.AppFlowy.metainfo.xml | 38 ++++++++++ .../packaging/io.appflowy.AppFlowy.service | 3 + .../linux_distribution/packaging/launcher.sh | 4 + frontend/scripts/makefile/flutter.toml | 7 +- 20 files changed, 260 insertions(+), 38 deletions(-) delete mode 100644 frontend/appflowy_flutter/linux/appflowy.desktop.temp mode change 100644 => 100755 frontend/scripts/code_generation/flowy_icons/generate_flowy_icons.sh create mode 100644 frontend/scripts/linux_distribution/appimage/AppImageBuilder.yml create mode 100644 frontend/scripts/linux_distribution/appimage/build_appimage.sh create mode 100644 frontend/scripts/linux_distribution/appimage/io.appflowy.AppFlowy.desktop create mode 100644 frontend/scripts/linux_distribution/deb/AppFlowy.desktop create mode 100644 frontend/scripts/linux_distribution/deb/DEBIAN/control create mode 100755 frontend/scripts/linux_distribution/deb/DEBIAN/postinst create mode 100755 frontend/scripts/linux_distribution/deb/DEBIAN/postrm create mode 100644 frontend/scripts/linux_distribution/deb/README.md create mode 100644 frontend/scripts/linux_distribution/deb/build_deb.sh create mode 100644 frontend/scripts/linux_distribution/flatpak/README.md create mode 100644 frontend/scripts/linux_distribution/packaging/appflowy.svg create mode 100644 frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.launcher.desktop create mode 100644 frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.metainfo.xml create mode 100644 frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.service create mode 100644 frontend/scripts/linux_distribution/packaging/launcher.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ec8603125..620da805dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -394,7 +394,7 @@ jobs: if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} working-directory: frontend run: | - sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + sudo apt-get install -qy binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libgtk-3-0 - name: Build AppFlowy working-directory: frontend @@ -402,34 +402,15 @@ jobs: flutter config --enable-linux-desktop dart ./scripts/flutter_release_build/build_flowy.dart run . ${{ github.ref_name }} - - name: Archive Assert + - name: Archive Asset working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} run: tar -czf ${{ env.LINUX_ZIP_NAME }} * - - name: Configuring Linux Package + - name: Build Linux package (.deb) working-directory: frontend run: | - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/opt - mkdir -p ../${{ env.LINUX_APP_RELEASE_PATH }}/package/usr/share/applications - cp -r ./scripts/linux_installer ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - cd ../${{ env.LINUX_APP_RELEASE_PATH }}/package/DEBIAN - grep -rl "\[CHANGE_THIS\]" ./control | xargs sed -i "s/\[CHANGE_THIS\]/${{ github.ref_name }}/" - chmod 0755 {postinst,postrm} - - - name: Build Linux package - working-directory: ${{ env.LINUX_APP_RELEASE_PATH }} - run: | - mv AppFlowy package/opt/ - cd package - - # Update Exec & icon path in desktop entry - grep -rl "\[CHANGE_THIS\]" ./opt/AppFlowy/appflowy.desktop.temp | xargs sed -i "s/\[CHANGE_THIS\]/\/opt/" - # Add desktop entry in package - mv ./opt/AppFlowy/appflowy.desktop.temp ./usr/share/applications/appflowy.desktop - - # Build - cd ../ && dpkg-deb --build --root-owner-group -Z xz package ${{ env.LINUX_PACKAGE_NAME }} - + sh scripts/linux_distribution/deb/build_deb.sh appflowy_flutter/product/${{ github.ref_name }}/linux/Release ${{ github.ref_name }} ${{ env.LINUX_PACKAGE_NAME }} + - name: Upload Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -441,7 +422,7 @@ jobs: asset_name: ${{ env.LINUX_ZIP_NAME }} asset_content_type: application/octet-stream - - name: Upload Asset Install Package + - name: Upload Debian package id: upload-release-asset-install-package uses: actions/upload-release-asset@v1 env: diff --git a/.gitignore b/.gitignore index bce47974c4..3b0b860e55 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,7 @@ pubspec.lock .fvm/ **/AppFlowy-Collab/ + +# ignore the deb filegit +frontend/package +frontend/*.deb diff --git a/frontend/appflowy_flutter/linux/appflowy.desktop.temp b/frontend/appflowy_flutter/linux/appflowy.desktop.temp deleted file mode 100644 index 2b189ef243..0000000000 --- a/frontend/appflowy_flutter/linux/appflowy.desktop.temp +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Name=AppFlowy -Comment=An Open Source Alternative to Notion -Icon=[CHANGE_THIS]/AppFlowy/flowy_logo.svg -Exec=[CHANGE_THIS]/AppFlowy/AppFlowy -Categories=Office -Type=Application -Terminal=false \ No newline at end of file diff --git a/frontend/scripts/code_generation/flowy_icons/generate_flowy_icons.sh b/frontend/scripts/code_generation/flowy_icons/generate_flowy_icons.sh old mode 100644 new mode 100755 diff --git a/frontend/scripts/linux_distribution/appimage/AppImageBuilder.yml b/frontend/scripts/linux_distribution/appimage/AppImageBuilder.yml new file mode 100644 index 0000000000..e7a9ba3655 --- /dev/null +++ b/frontend/scripts/linux_distribution/appimage/AppImageBuilder.yml @@ -0,0 +1,76 @@ +# appimage-builder recipe see https://appimage-builder.readthedocs.io for details +version: 1 +script: + - rm -rf AppDir || true + - cp -r appflowy_flutter/build/linux/x64/release/bundle AppDir + + # Icon + - mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps + - cp scripts/linux_distribution/packaging/appflowy.svg AppDir/usr/share/icons/hicolor/scalable/apps/ + +AppDir: + path: ./AppDir + app_info: + id: io.appflowy.AppFlowy + name: AppFlowy + icon: appflowy.svg + version: [CHANGE_THIS] + exec: AppFlowy + exec_args: $@ + apt: + arch: + - amd64 + allow_unauthenticated: true + sources: + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy main restricted + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy-updates main restricted + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy universe + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy-updates universe + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy multiverse + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy-updates multiverse + - sourceline: deb http://id.archive.ubuntu.com/ubuntu/ jammy-backports main restricted + universe multiverse + - sourceline: deb http://security.ubuntu.com/ubuntu jammy-security main restricted + - sourceline: deb http://security.ubuntu.com/ubuntu jammy-security universe + - sourceline: deb http://security.ubuntu.com/ubuntu jammy-security multiverse + - sourceline: deb https://ppa.launchpadcontent.net/touchegg/stable/ubuntu/ jammy + main + - sourceline: deb https://packagecloud.io/slacktechnologies/slack/debian/ jessie + main + - sourceline: deb [arch=amd64 signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] + https://cli.github.com/packages stable main + - sourceline: deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x + jammy main + - sourceline: deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code + stable main + - sourceline: deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable + main + include: + - libc6:amd64 + files: + include: [] + exclude: + - usr/share/man + - usr/share/doc/*/README.* + - usr/share/doc/*/changelog.* + - usr/share/doc/*/NEWS.* + - usr/share/doc/*/TODO.* + test: + fedora-30: + image: appimagecrafters/tests-env:fedora-30 + command: ./AppRun + debian-stable: + image: appimagecrafters/tests-env:debian-stable + command: ./AppRun + archlinux-latest: + image: appimagecrafters/tests-env:archlinux-latest + command: ./AppRun + centos-7: + image: appimagecrafters/tests-env:centos-7 + command: ./AppRun + ubuntu-xenial: + image: appimagecrafters/tests-env:ubuntu-xenial + command: ./AppRun +AppImage: + arch: x86_64 + update-information: guess \ No newline at end of file diff --git a/frontend/scripts/linux_distribution/appimage/build_appimage.sh b/frontend/scripts/linux_distribution/appimage/build_appimage.sh new file mode 100644 index 0000000000..3132aa8030 --- /dev/null +++ b/frontend/scripts/linux_distribution/appimage/build_appimage.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +VERSION=$1 + +# if the appimage-builder not exist, download it +if [ ! -e /usr/local/bin/appimage-builder ]; then + wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage + chmod +x appimage-builder-x86_64.AppImage + + # install (optional) + sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder +fi + + +# update version +grep -rl "\[CHANGE_THIS\]" scripts/linux_distribution/appimage/AppImageBuilder.yml | xargs sed -i "s/\[CHANGE_THIS\]/$VERSION/" + +appimage-builder --recipe scripts/linux_distribution/appimage/AppImageBuilder.yml diff --git a/frontend/scripts/linux_distribution/appimage/io.appflowy.AppFlowy.desktop b/frontend/scripts/linux_distribution/appimage/io.appflowy.AppFlowy.desktop new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frontend/scripts/linux_distribution/deb/AppFlowy.desktop b/frontend/scripts/linux_distribution/deb/AppFlowy.desktop new file mode 100644 index 0000000000..fb023f546b --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/AppFlowy.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=AppFlowy +Icon=/usr/share/icons/hicolor/scalable/apps/appflowy.svg +Exec=env GDK_GL=gles /usr/bin/AppFlowy %U +Categories=Network;Productivity; +Keywords=Notes +DBusActivatable=true +Implements=io.appflowy.AppFlowy; +Terminal=false \ No newline at end of file diff --git a/frontend/scripts/linux_distribution/deb/DEBIAN/control b/frontend/scripts/linux_distribution/deb/DEBIAN/control new file mode 100644 index 0000000000..bcdd830fe6 --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/DEBIAN/control @@ -0,0 +1,8 @@ +Package: AppFlowy +Version: [CHANGE_THIS] +Depends: libkeybinder-3.0-0 +Architecture: amd64 +Essential: no +Priority: optional +Maintainer: AppFlowy +Description: An Open Source Alternative to Notion diff --git a/frontend/scripts/linux_distribution/deb/DEBIAN/postinst b/frontend/scripts/linux_distribution/deb/DEBIAN/postinst new file mode 100755 index 0000000000..56186649d4 --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/DEBIAN/postinst @@ -0,0 +1,8 @@ +#!/bin/bash +if [ -e /usr/bin/AppFlowy ]; then + echo "Symlink already exists, skipping." +else + echo "Creating Symlink in /usr/bin/appflowy" + ln -s /usr/lib/AppFlowy/AppFlowy /usr/bin/AppFlowy + ln -s /usr/lib/AppFlowy/launcher.sh /usr/bin/AppFlowyLauncher.sh +fi diff --git a/frontend/scripts/linux_distribution/deb/DEBIAN/postrm b/frontend/scripts/linux_distribution/deb/DEBIAN/postrm new file mode 100755 index 0000000000..f815d1bb5c --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/DEBIAN/postrm @@ -0,0 +1,5 @@ +#!/bin/bash +if [ -e /usr/bin/AppFlowy ]; then + rm /usr/bin/AppFlowy + rm /usr/bin/AppFlowyLauncher.sh +fi diff --git a/frontend/scripts/linux_distribution/deb/README.md b/frontend/scripts/linux_distribution/deb/README.md new file mode 100644 index 0000000000..58304ebc99 --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/README.md @@ -0,0 +1,18 @@ +# Build AppFlowy for Debian + +## Prerequisites + +- dpkg-deb +- make sure you have built the app for Linux which is located in `frontend/appflowy_flutter/production/$VERSION/linux/Release/` + +## Build + +```bash +cd frontend/ +sh scripts/linux_distribution/deb/build_deb.sh [LINUX_PRODUCTION_RELEASE_PATH] [VERSION] [PACKAGE_NAME] + +# for example +sh scripts/linux_distribution/deb/build_deb.sh appflowy_flutter/product/0.2.9/linux/Release 0.2.9 AppFlowy_0.2.9.deb +``` + +The deb file will be located in '[LINUX_PRODUCTION_RELEASE_PATH]/[PACKAGE_NAME]' diff --git a/frontend/scripts/linux_distribution/deb/build_deb.sh b/frontend/scripts/linux_distribution/deb/build_deb.sh new file mode 100644 index 0000000000..5bf36aa61e --- /dev/null +++ b/frontend/scripts/linux_distribution/deb/build_deb.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +LINUX_RELEASE_PRODUCTION=$1 +VERSION=$2 +PACKAGE_NAME=$3 + +# Define package folders +PACKAGE=$LINUX_RELEASE_PRODUCTION/package +LIB=$PACKAGE/usr/lib +APPLICATIONS=$PACKAGE/usr/share/applications +DBUS_SERVICES=$PACKAGE/usr/share/dbus-1/services +ICONS=$PACKAGE/usr/share/icons/hicolor/scalable/apps +METAINFO=$PACKAGE/usr/share/metainfo +DEBIAN=$PACKAGE/DEBIAN + +# Create package folder +mkdir -p $LIB +mkdir -p $APPLICATIONS +mkdir -p $DBUS_SERVICES +mkdir -p $ICONS +mkdir -p $METAINFO +mkdir -p $DEBIAN + +# Configure the package +cp -R ./scripts/linux_distribution/deb/DEBIAN $PACKAGE +chmod 0755 $DEBIAN/postinst +chmod 0755 $DEBIAN/postrm +grep -rl "\[CHANGE_THIS\]" $DEBIAN/control | xargs sed -i "s/\[CHANGE_THIS\]/$VERSION/" + +cp -fR $LINUX_RELEASE_PRODUCTION/AppFlowy $LIB +cp ./scripts/linux_distribution/packaging/launcher.sh $LIB/AppFlowy +chmod +x $LIB/AppFlowy/launcher.sh + +cp ./scripts/linux_distribution/deb/AppFlowy.desktop $APPLICATIONS +cp ./scripts/linux_distribution/packaging/io.appflowy.AppFlowy.launcher.desktop $APPLICATIONS + +cp ./scripts/linux_distribution/packaging/io.appflowy.AppFlowy.metainfo.xml $METAINFO +cp ./scripts/linux_distribution/packaging/io.appflowy.AppFlowy.service $DBUS_SERVICES +cp ./scripts/linux_distribution/packaging/appflowy.svg $ICONS + +# Build the package +dpkg-deb --build --root-owner-group -Z xz $PACKAGE $LINUX_RELEASE_PRODUCTION/$PACKAGE_NAME diff --git a/frontend/scripts/linux_distribution/flatpak/README.md b/frontend/scripts/linux_distribution/flatpak/README.md new file mode 100644 index 0000000000..7d90cfd2a6 --- /dev/null +++ b/frontend/scripts/linux_distribution/flatpak/README.md @@ -0,0 +1 @@ +Please refer to https://github.com/flathub/io.appflowy.AppFlowy repo. diff --git a/frontend/scripts/linux_distribution/packaging/appflowy.svg b/frontend/scripts/linux_distribution/packaging/appflowy.svg new file mode 100644 index 0000000000..6b5430bfa0 --- /dev/null +++ b/frontend/scripts/linux_distribution/packaging/appflowy.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.launcher.desktop b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.launcher.desktop new file mode 100644 index 0000000000..7fa344a3bd --- /dev/null +++ b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.launcher.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Application +Name=AppFlowy Launcher +Exec=AppFlowyLauncher.sh %u +MimeType=x-scheme-handler/appflowy-flutter; +NoDisplay=true \ No newline at end of file diff --git a/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.metainfo.xml b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.metainfo.xml new file mode 100644 index 0000000000..c9a58b68fa --- /dev/null +++ b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.metainfo.xml @@ -0,0 +1,38 @@ + + + io.appflowy.AppFlowy + + AppFlowy + Open Source Notion Alternative + + CC-BY-4.0 + AGPL-3.0-only + + +

+ # Built for teams that need more control and flexibility ## 100% data control You can host AppFlowy wherever you want; no vendor lock-in. +

+

+ ## Unlimited customizations Design and modify AppFlowy your way with an open core codebase. +

+

+ ## One codebase supporting multiple platforms AppFlowy is built with Flutter and Rust. What does this mean? Faster development, better native experience, and more reliable performance. +

+

+ # Built for individuals who care about data security and mobile experience ## 100% control of your data Download and install AppFlowy on your local machine. You own and control your personal data. +

+

+ ## Extensively extensible For those with no coding experience, AppFlowy enables you to create apps that suit your needs. It's built on a community-driven toolbox, including templates, plugins, themes, and more. +

+

+ ## Truly native experience Faster, more stable with support for offline mode. It's also better integrated with different devices. Moreover, AppFlowy enables users to access features and possibilities not available on the web. +

+
+ + io.appflowy.AppFlowy.desktop + + + https://github.com/AppFlowy-IO/appflowy/raw/main/doc/imgs/welcome.png + + +
diff --git a/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.service b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.service new file mode 100644 index 0000000000..31e32415d0 --- /dev/null +++ b/frontend/scripts/linux_distribution/packaging/io.appflowy.AppFlowy.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=io.appflowy.AppFlowy +Exec=AppFlowy diff --git a/frontend/scripts/linux_distribution/packaging/launcher.sh b/frontend/scripts/linux_distribution/packaging/launcher.sh new file mode 100644 index 0000000000..c7e7b9ee4a --- /dev/null +++ b/frontend/scripts/linux_distribution/packaging/launcher.sh @@ -0,0 +1,4 @@ +#!/bin/bash +gdbus call --session --dest io.appflowy.AppFlowy \ + --object-path /io/appflowy/AppFlowy/Object \ + --method io.appflowy.AppFlowy.Open "['$1']" {} diff --git a/frontend/scripts/makefile/flutter.toml b/frontend/scripts/makefile/flutter.toml index 8319d0d2bf..2ebae49026 100644 --- a/frontend/scripts/makefile/flutter.toml +++ b/frontend/scripts/makefile/flutter.toml @@ -120,9 +120,6 @@ script = [ product=${PRODUCT_NAME} cp -R ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/build/${TARGET_OS}/${LINUX_ARCH}/${BUILD_FLAG}/bundle \ ${output_path}/${product} - - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/linux/appflowy.desktop.temp ${output_path}/${product} - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/assets/images/flowy_logo.svg ${output_path}/${product} """, ] script_runner = "@shell" @@ -164,8 +161,8 @@ linux_alias = "create-release-archive-linux" [tasks.create-release-archive-linux] script = [ - "cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/product/${APP_VERSION}/${TARGET_OS}/Release", - "tar -czf ${PRODUCT_NAME}-${TARGET_OS}-x86.tar.gz *", + # "cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/product/${APP_VERSION}/${TARGET_OS}/Release", + # "tar -czf ${PRODUCT_NAME}-${TARGET_OS}-x86.tar.gz *", ] [tasks.create-release-archive-windows]