diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml index bb2889983b..15ef794610 100644 --- a/.github/workflows/build-desktop.yml +++ b/.github/workflows/build-desktop.yml @@ -166,7 +166,7 @@ jobs: - name: Set up environment run: | sudo apt-get update - sudo apt-get -y install pkg-config libxss-dev libsecret-1-dev rpm musl-dev musl-tools + sudo apt-get -y install pkg-config libxss-dev libsecret-1-dev rpm musl-dev musl-tools flatpak flatpak-builder - name: Set up Snap run: sudo snap install snapcraft --classic @@ -248,6 +248,19 @@ jobs: name: ${{ needs.setup.outputs.release_channel }}-linux.yml path: apps/desktop/dist/${{ needs.setup.outputs.release_channel }}-linux.yml if-no-files-found: error + + - name: Build flatpak + working-directory: apps/desktop + run: | + sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + sudo npm run pack:lin:flatpak + + - name: Upload flatpak artifact + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: com.bitwarden.desktop.flatpak + path: apps/desktop/dist/com.bitwarden.desktop.flatpak + if-no-files-found: error windows: diff --git a/.gitignore b/.gitignore index 6dea4b43f1..d0d8edd596 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ npm-debug.log dist build .angular/cache +.flatpak +.flatpak-repo +.flatpak-builder # Testing coverage diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 423650cdce..ae19e5f93c 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -34,6 +34,7 @@ "electron:ignore": "node ./scripts/start.js --ignore-certificate-errors", "clean:dist": "rimraf ./dist", "pack:dir": "npm run clean:dist && electron-builder --dir -p never", + "pack:lin:flatpak": "npm run clean:dist && electron-builder --dir -p never && flatpak-builder --repo=build/.repo build/.flatpak ./resources/com.bitwarden.desktop.devel.yaml --install-deps-from=flathub --force-clean && flatpak build-bundle ./build/.repo/ ./dist/com.bitwarden.desktop.flatpak com.bitwarden.desktop", "pack:lin": "npm run clean:dist && electron-builder --linux --x64 -p never", "pack:mac": "npm run clean:dist && electron-builder --mac --universal -p never", "pack:mac:arm64": "npm run clean:dist && electron-builder --mac --arm64 -p never", diff --git a/apps/desktop/resources/com.bitwarden.desktop.devel.yaml b/apps/desktop/resources/com.bitwarden.desktop.devel.yaml new file mode 100644 index 0000000000..234d37905c --- /dev/null +++ b/apps/desktop/resources/com.bitwarden.desktop.devel.yaml @@ -0,0 +1,43 @@ +app-id: com.bitwarden.desktop +runtime: org.freedesktop.Platform +runtime-version: "24.08" +sdk: org.freedesktop.Sdk +base: org.electronjs.Electron2.BaseApp +base-version: "24.08" +command: bitwarden.sh +finish-args: + - --share=ipc + - --share=network + - --socket=wayland + - --socket=x11 + - --device=dri + - --env=XDG_CURRENT_DESKTOP=Unity + - --env=XCURSOR_PATH=/run/host/user-share/icons:/run/host/share/icons + - --talk-name=org.kde.StatusNotifierWatcher + - --talk-name=org.freedesktop.Notifications + - --talk-name=org.freedesktop.secrets + - --talk-name=com.canonical.AppMenu.Registrar + - --system-talk-name=org.freedesktop.PolicyKit1 + # Lock on lockscreen + - --talk-name=org.gnome.ScreenSaver + - --talk-name=org.freedesktop.ScreenSaver + - --system-talk-name=org.freedesktop.login1 + - --filesystem=xdg-download +modules: + - name: bitwarden-desktop + buildsystem: simple + build-commands: + - mkdir -p /app/bin + - mkdir -p /app/bin/Bitwarden/ + - cp -r ./* /app/bin/ + - install bitwarden.sh /app/bin/bitwarden.sh + sources: + - type: dir + path: ../dist/linux-unpacked + - type: script + dest-filename: bitwarden.sh + commands: + - ulimit -c 0 + - export TMPDIR="$XDG_RUNTIME_DIR/app/$FLATPAK_ID" + - exec zypak-wrapper /app/bin/bitwarden-app --ozone-platform-hint=auto + --enable-features=WaylandWindowDecorations "$@"