Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
run: yarn run build

- name: Test
run: yarn run test
run: yarn run test
80 changes: 80 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,83 @@ jobs:
name: macos-${{ matrix.target }}
path: dist/grist-desktop-*.dmg
if-no-files-found: "error"

flatpak:
runs-on: ubuntu-22.04
name: Flatpak build
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Submodule cleanup fix # See https://github.com/actions/checkout/issues/358
run: |
git submodule foreach --recursive git clean -ffdx
git submodule foreach --recursive git reset --hard

- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: actions/cache@v4
id: yarn-cache
with:
path: |
node_modules
core/node_modules
key: ubuntu-22.04-x64-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
ubuntu-22.04-x64-yarn-

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --network-timeout 300000 --ignore-optional

- name: Hooks and crooks
run: yarn run setup
env:
RUN_OS: ubuntu-22.04
RUN_ARCH: x64

- name: Build
run: yarn run build

- name: Test
run: yarn run test

- name: Install Flatpak dependencies
run: |
sudo apt-get update
sudo apt-get install -y flatpak flatpak-builder librsvg2-bin

- name: Package Flatpak
run: |
# Generate PNG icons for Flatpak
mkdir -p dist/icons
for size in 16 32 48 64 128 256 512; do
rsvg-convert -w "$size" -h "$size" core/static/icons/grist.svg -o "dist/icons/${size}x${size}.png"
done
cp core/static/icons/grist.svg dist/icons/scalable.svg

# Add flathub remote with sudo
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# Install required runtimes with sudo
sudo flatpak install -y --noninteractive flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 org.electronjs.Electron2.BaseApp//23.08

# Build Flatpak package
yarn run electron:flatpak
env:
GITHUB_TOKEN: ${{ github.token }}
DEBUG: electron-builder

- name: Upload Flatpak build
uses: actions/upload-artifact@v4
with:
name: linux-flatpak
path: dist/grist-desktop-*.flatpak
if-no-files-found: "error"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ _build
stash
NOTES.txt
dock
.flatpak-tmp/
3 changes: 2 additions & 1 deletion ext/app/electron/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export function setupLogging() {
output.on("error", (err) => log.error("Failed to open %s: %s", debugLogPath, err));
output.on("open", () => {
log.info("Logging also to %s", debugLogPath);
output.write("\n--- log starting by pid " + process.pid + " ---\n");
const pid = process.pid || 'unknown';
output.write("\n--- log starting by pid " + pid + " ---\n");

const fileTransportOptions = {
name: "debugLog",
Expand Down
58 changes: 51 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"repository": "https://github.com/gristlabs/grist-desktop",
"author": "Grist Labs Inc. <[email protected]>",
"license": "Apache-2.0",
"desktopName": "com.getgrist.grist",
"workspaces": {
"packages": [
"core",
Expand All @@ -31,6 +32,7 @@
"electron:preview": "electron --trace-warnings core/_build/ext/app/electron/main.js",
"electron:dir": "electron-builder build --linux --dir",
"electron:linux": "electron-builder build --linux",
"electron:flatpak": "electron-builder build --linux flatpak",
"electron:ci": "./scripts/ci.sh",
"electron": "electron-builder build --publish never",
"test": "electron core/_build/ext/app/electron/main.js --version"
Expand All @@ -41,20 +43,16 @@
"chromedriver": "110.0.0"
},
"build": {
"appId": "com.getgrist.desktop",
"appId": "com.getgrist.grist",
"npmRebuild": false,
"compression": "normal",
"includeSubNodeModules": true,
"icon": "core/static/icons/grist.png",
"win": {
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
"target": [
{
"target": "nsis"
},
{
"target": "zip"
}
{"target": "nsis"},
{"target": "zip"}
],
"icon": "core/static/icons/grist.ico"
},
Expand All @@ -79,6 +77,52 @@
"icon": "core/static/icons/grist.png",
"target": "AppImage"
},
"flatpak": {
"branch": "stable",
"runtime": "org.freedesktop.Platform",
"runtimeVersion": "23.08",
"sdk": "org.freedesktop.Sdk",
"base": "org.electronjs.Electron2.BaseApp",
"baseVersion": "23.08",
"finishArgs": [
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--socket=pulseaudio",
"--device=dri",
"--talk-name=org.freedesktop.Notifications",
"--talk-name=org.freedesktop.secrets",
"--filesystem=home",
"--allow=multiarch",
"--filesystem=xdg-cache/tmp:create",
"--env=TMPDIR=/tmp",
"--env=GRIST_SANDBOX_FLAVOR=unsandboxed"
],
"desktop": {
"Name": "Grist",
"Comment": "Spreadsheet software to end data chaos",
"Icon": "com.getgrist.grist",
"Categories": ["Office"],
"MimeType": "text/csv;text/tab-separated-values;text/plain;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroEnabled.12;"
},
"mimeTypes": [
"text/csv",
"text/tab-separated-values",
"text/plain",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.ms-excel.sheet.macroEnabled.12"
],
"files": [
["dist/icons/16x16.png", "/app/share/icons/hicolor/16x16/apps/com.getgrist.grist.png"],
["dist/icons/32x32.png", "/app/share/icons/hicolor/32x32/apps/com.getgrist.grist.png"],
["dist/icons/48x48.png", "/app/share/icons/hicolor/48x48/apps/com.getgrist.grist.png"],
["dist/icons/64x64.png", "/app/share/icons/hicolor/64x64/apps/com.getgrist.grist.png"],
["dist/icons/128x128.png", "/app/share/icons/hicolor/128x128/apps/com.getgrist.grist.png"],
["dist/icons/256x256.png", "/app/share/icons/hicolor/256x256/apps/com.getgrist.grist.png"],
["dist/icons/512x512.png", "/app/share/icons/hicolor/512x512/apps/com.getgrist.grist.png"],
["dist/icons/scalable.svg", "/app/share/icons/hicolor/scalable/apps/com.getgrist.grist.svg"]
]
},
"afterSign": "./scripts/notarize.js",
"asarUnpack": [
"core/plugins",
Expand Down
42 changes: 42 additions & 0 deletions scripts/flatpak-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -euo pipefail

ICON_SRC="core/static/icons/grist.svg"
ICON_OUT_DIR="dist/icons/"
SIZES=(16 32 48 64 128 256 512)

echo "Checking Flatpak tooling..."
command -v flatpak >/dev/null || { echo "flatpak not found. Please install flatpak"; exit 1; }
command -v flatpak-builder >/dev/null || { echo "flatpak-builder not found. Please install flatpak-builder"; exit 1; }
command -v rsvg-convert >/dev/null || { echo "rsvg-convert not found. Please install librsvg2-bin"; exit 1; }

echo "Generating PNG icons for Flatpak..."
mkdir -p "$ICON_OUT_DIR"
for size in "${SIZES[@]}"; do
rsvg-convert -w "$size" -h "$size" "$ICON_SRC" -o "$ICON_OUT_DIR/${size}x${size}.png"
done

echo "Copying SVG icon for Flatpak..."
cp "$ICON_SRC" "$ICON_OUT_DIR/scalable.svg"

echo "Ensuring Flathub remote exists (needed for runtimes)..."
if ! flatpak remote-list | grep -q "^flathub"; then
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
fi

echo "Installing required runtimes if missing..."
flatpak install -y --noninteractive flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 org.electronjs.Electron2.BaseApp//23.08 || true

echo "Installing dependencies..."
yarn install

echo "Project setup (Python env etc.)..."
yarn run setup

echo "Building app (production)..."
yarn run build

echo "Packaging Flatpak..."
yarn run electron:flatpak

echo "Done. Look in the dist/ folder for the .flatpak file."
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7239,18 +7239,18 @@ lowercase-keys@^2.0.0:
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479"
integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==

lru-cache@^10.2.0, lru-cache@^10.4.3:
version "10.4.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==

lru-cache@^5.1.1:
[email protected], lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==
dependencies:
yallist "^3.0.2"

lru-cache@^10.2.0, lru-cache@^10.4.3:
version "10.4.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
Expand Down