Skip to content

Commit

Permalink
Merge branch 'main' into feat/improve-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed Jan 27, 2024
2 parents 8295625 + 06674df commit df15eb7
Show file tree
Hide file tree
Showing 23 changed files with 441 additions and 157 deletions.
44 changes: 44 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Dependencies
**/node_modules
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
**/.next/
**/out/
**/build
**/dist
**/target


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem

# Unnecessary files
**/.git/
.github/
flatpak/*.xml
flatpak/*.desktop
flatpak/*.yml
77 changes: 77 additions & 0 deletions .github/workflows/flatpak-bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
on:
push:
# NOTE: Proposal to make this action available only for tags
#tags:
#- 'v*.*.*'

name: flatpak build
jobs:
prepare-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: cache of container
id: cache-container
uses: actions/cache@v3
with:
path: prepare-dist
key: ${{ runner.os }}-container-${{ hashFiles('prepare-dist') }}
- name: Run latest-tag
id: latest-tag
uses: oprypin/find-latest-tag@v1
with:
repository:
luminous-devs/lume
#FIXME: luminous-devs after merged fix, now it just won't find tags
# repository: ${{ github.repository }}

- name: Build container
# if: steps.cache-container.outputs.cache-hit != 'true'
run: |
docker buildx build -t flatpak-prepare-lume --build-arg=${{steps.latest-tag.outputs.tag}} --rm --output=. --target=final -f flatpak/Containerfile .
- name: Copy flatpak files content
run: |
cp -r flatpak/*.xml flatpak/*.desktop flatpak/*.yml prepare-dist
- uses: actions/upload-artifact@v4
with:
name: repo-dist
path: prepare-dist

flatpak:
name: flatpak-bundle
needs: prepare-repo
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
options: --privileged
steps:
- uses: actions/download-artifact@v4
with:
name: repo-dist
- uses: actions/checkout@v4
with:
repository: flathub/shared-modules
path: shared-modules
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: lume.flatpak
manifest-path: nu.lume.Lume.yml
restore-cache: false
# cache-key: flatpak-builder-${{ github.sha }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
append_body: true
files: lume.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: geekyeggo/delete-artifact@v4
with:
name: repo-dist
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 6 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,23 @@ node_modules
.env.production.local

# Testing
coverage
coverage/

# Turbo
.turbo
.turbo/

# Vercel
.vercel
.vercel/

# Build Outputs
.next/
out/
build
dist
build/
dist/


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.log*

# Misc
.DS_Store
Expand Down
7 changes: 4 additions & 3 deletions apps/desktop/src/routes/depot/components/members.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { CancelIcon, PlusIcon, UserAddIcon, UserRemoveIcon } from "@lume/icons";
import { User } from "@lume/ui";
import * as Dialog from "@radix-ui/react-dialog";
import { resolveResource } from "@tauri-apps/api/path";
import { resolveResource, resolve } from "@tauri-apps/api/path";
import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
import { nip19 } from "nostr-tools";
import { useEffect, useState } from "react";
import { parse, stringify } from "smol-toml";
import { toast } from "sonner";
import { VITE_FLATPAK_RESOURCE } from "@lume/utils";

export function DepotMembers() {
const [members, setMembers] = useState<Set<string>>(null);
Expand All @@ -32,7 +33,7 @@ export function DepotMembers() {
const updateMembers = async () => {
setMembers(new Set(tmpMembers));

const defaultConfig = await resolveResource("resources/config.toml");
const defaultConfig = VITE_FLATPAK_RESOURCE !== null ? await resolve("/",VITE_FLATPAK_RESOURCE) : await resolveResource("resources/config.toml");
const config = await readTextFile(defaultConfig);
const configContent = parse(config);

Expand All @@ -46,7 +47,7 @@ export function DepotMembers() {

useEffect(() => {
async function loadConfig() {
const defaultConfig = await resolveResource("resources/config.toml");
const defaultConfig = VITE_FLATPAK_RESOURCE !== null ? await resolve("/",VITE_FLATPAK_RESOURCE) : await resolveResource("resources/config.toml");
const config = await readTextFile(defaultConfig);
const configContent = parse(config);
setTmpMembers(
Expand Down
9 changes: 6 additions & 3 deletions apps/desktop/src/routes/depot/onboarding.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useArk } from "@lume/ark";
import { LoaderIcon } from "@lume/icons";
import { delay, VITE_FLATPAK_RESOURCE } from "@lume/utils";
import { resolve, resolveResource } from "@tauri-apps/api/path";
import { useStorage } from "@lume/storage";
import { delay } from "@lume/utils";
import { resolveResource } from "@tauri-apps/api/path";
import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
Expand All @@ -21,7 +21,10 @@ export function DepotOnboardingScreen() {
setLoading(true);

// get default config
const defaultConfig = await resolveResource("resources/config.toml");
const defaultConfig =
VITE_FLATPAK_RESOURCE !== null
? await resolve("/", VITE_FLATPAK_RESOURCE)
: await resolveResource("resources/config.toml");
const config = await readTextFile(defaultConfig);
const parsedConfig = parse(config);

Expand Down
13 changes: 13 additions & 0 deletions flatpak/0001-disable-tauri-updater.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 21f5d9a5..9a46f36d 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -64,7 +64,7 @@
"shortDescription": "",
"targets": "all",
"updater": {
- "active": true,
+ "active": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU3OTdCMkM3RjU5QzE2NzkKUldSNUZwejF4N0tYNTVHYjMrU0JkL090SlEyNUVLYU5TM2hTU3RXSWtEWngrZWJ4a0pydUhXZHEK",
"windows": {
"installMode": "quiet"
13 changes: 13 additions & 0 deletions flatpak/0002-depot-remove.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 87c23e40..bb84872e 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -50,8 +50,6 @@
"deb": {
"depends": []
},
- "externalBin": ["bin/depot"],
- "resources": ["resources/*"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
61 changes: 61 additions & 0 deletions flatpak/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM node:20-slim as prepare

RUN apt update && apt install -y git

# Taken from tauri docs https://beta.tauri.app/guides/prerequisites/#rust
RUN apt install libwebkit2gtk-4.1-dev -y \
build-essential \
curl \
wget \
file \
libssl-dev \
libayatana-appindicator3-dev \
protobuf-compiler \
librsvg2-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y


FROM prepare as build

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV PATH="/root/.cargo/bin:${PATH}"

#RUN corepack prepare pnpm@latest --activate

RUN corepack enable

ADD . /lume/.

WORKDIR /lume

RUN pnpm install --frozen-lockfile

# Path for disable updater
#ADD flatpak/0001-disable-tauri-updater.patch .
#RUN patch -p1 -t -i flatpak/0001-disable-tauri-updater.patch
#ADD flatpak/0002-depot-remove.patch .
#RUN patch -p1 -t -i 0002-depot-remove.patch

# compile depot

#ADD flatpak/build-depot.sh build-depot.sh
#RUN mv flatpak/build-depot.sh build-depot.sh
#RUN sh build-depot.sh
#RUN pnpm run build:depot

#ENV VITE_FLATPAK_RESOURCE="/app/lib/lume/resources/config.toml"

# debian build
RUN pnpm tauri build -b deb

ARG VERSION=3.0.0
ARG ARCH=amd64

RUN cp -r ./src-tauri/target/release/bundle/deb/lume_${VERSION}_${ARCH}/data lume-package

FROM scratch as final

COPY --from=build lume/lume-package prepare-dist
#ADD flatpak/*.xml flatpak/*.desktop flatpak/*.yml prepare-dist
15 changes: 15 additions & 0 deletions flatpak/build-depot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

directory_bin="/lume/src-tauri/bin"
target="x86_64-unknown-linux-gnu"

cd modules/depot

check_directory_keep=$(ls $directory_bin | grep -vE '.keep$' | wc -l)

echo $(ls $directory_bin | grep -vE '.keep$')

if [ $check_directory_keep -eq 0 ]; then
cargo build --release
mv target/release/depot "$directory_bin/depot-$target"
fi
50 changes: 50 additions & 0 deletions flatpak/nu.lume.Lume.appdata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>nu.lume.Lume</id>
<launchable type="desktop-id">nu.lume.Lume.desktop</launchable>

<name>Lume</name>
<summary>A cross-platform desktop nostr client</summary>
<developer_name>Ren Amamiya</developer_name>

<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-only</project_license>

<url type="homepage">https://lume.nu</url>
<url type="bugtracker">https://github.com/luminous-devs/lume/issues</url>
<url type="donation">https://nostree.me/npub1zfss807aer0j26mwp2la0ume0jqde3823rmu97ra6sgyyg956e0s6xw445</url>

<supports>
<control>pointing</control>
<control>keyboard</control>
<control>touch</control>
</supports>

<description>
<p>
Lume a cross-platform nostr client, supported nsbunker, chats and notifications
</p>
</description>

<custom>
<value key="Purism::form_factor">workstation</value>
<value key="Purism::form_factor">mobile</value>
</custom>
<screenshots>
<screenshot type="default">
<image> https://raw.githubusercontent.com/kogeletey/lume-nostr/feat/package-flatpak/flatpak/screenshoots/login-screen.png </image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/kogeletey/lume-nostr/feat/package-flatpak/flatpak/screenshoots/collumns.png</image>
</screenshot>
<screenshot>
<image> https://raw.githubusercontent.com/kogeletey/lume-nostr/feat/package-flatpak/flatpak/screenshoots/home-screen.png </image>
</screenshot>
</screenshots>


<releases>
<release version="2.2.3" date="2023-12-07"/>
</releases>
<content_rating type="oars-1.1"/>
</component>
12 changes: 12 additions & 0 deletions flatpak/nu.lume.Lume.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Desktop Entry]
Version=1.0
Type=Application

Name=Lume
Comment=A cross-platform desktop nostr client
Icon=lume
Exec=lume
Terminal=false
Categories=Network;InstantMessaging;
Keywords=nostr;client;chat;
X-Purism-FormFactor=Workstation;
Loading

0 comments on commit df15eb7

Please sign in to comment.