Skip to content

Commit 7c74f19

Browse files
authored
Add Flatpak for Linux (#53)
1 parent 0da7f75 commit 7c74f19

7 files changed

Lines changed: 963 additions & 564 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,41 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v5
2222
- uses: volta-cli/action@v4
23-
# https://github.com/actions/runner/issues/2958
23+
# https://github.com/actions/runner/issues/2958#issuecomment-2186602747
2424
- if: matrix.os == 'macos'
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version: "3.13.7"
28-
- if: matrix.os == 'macos'
29-
run: pip install setuptools
25+
run: brew install python-setuptools
26+
# https://www.electronforge.io/config/makers/flatpak#requirements
27+
- if: matrix.os == 'ubuntu'
28+
run: |
29+
set -ex
30+
sudo apt-get update
31+
sudo apt-get install -y --no-install-recommends flatpak flatpak-builder elfutils
32+
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
3033
- run: npm ci
3134
- run: npm run lint
3235
- run: npm run format:check
33-
- run: npm run package
36+
- run: npm run make
3437
release:
3538
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
3639
needs: build
3740
strategy:
3841
matrix:
39-
os: [macos, windows]
42+
os: [macos, windows, ubuntu]
4043
fail-fast: false
4144
runs-on: "${{ matrix.os }}-latest"
4245
steps:
4346
- uses: actions/checkout@v5
4447
- uses: volta-cli/action@v4
45-
# https://github.com/actions/runner/issues/2958
46-
- if: matrix.os == 'macos'
47-
uses: actions/setup-python@v5
48-
with:
49-
python-version: "3.13.7"
48+
# https://github.com/actions/runner/issues/2958#issuecomment-2186602747
5049
- if: matrix.os == 'macos'
51-
run: pip install setuptools
50+
run: brew install python-setuptools
51+
# https://www.electronforge.io/config/makers/flatpak#requirements
52+
- if: matrix.os == 'ubuntu'
53+
run: |
54+
set -ex
55+
sudo apt-get update
56+
sudo apt-get install -y --no-install-recommends flatpak flatpak-builder elfutils
57+
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
5258
- run: npm ci
5359
- run: npm version --no-git-tag-version "${{ github.ref_name }}"
5460
- run: npm run make
@@ -58,3 +64,4 @@ jobs:
5864
files: |
5965
out/make/**/*.exe
6066
out/make/**/*.dmg
67+
out/make/**/*.flatpak

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ typings/
8787

8888
# Electron-Forge
8989
out/
90+
.flatpak-builder/
9091

9192
# Electron Vite
9293
dist/

forge.config.js

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,85 @@ import path from "node:path";
44

55
import { MakerDMG } from "@electron-forge/maker-dmg";
66
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
7+
import { MakerFlatpak } from "@electron-forge/maker-flatpak";
78

8-
const getAppIcon = () => {
9-
const iconExtension =
10-
process.platform === "win32"
11-
? "ico"
12-
: process.platform === "darwin"
13-
? "icns"
14-
: "png";
15-
16-
return path.resolve(
17-
import.meta.dirname,
18-
`./resources/appicons/${iconExtension}/icon.${iconExtension}`,
19-
);
20-
};
9+
const iconExtension =
10+
process.platform === "win32"
11+
? "ico"
12+
: process.platform === "darwin"
13+
? "icns"
14+
: "png";
15+
const iconRelative = `resources/appicons/${iconExtension}/icon.${iconExtension}`;
16+
const icon = path.join(import.meta.dirname, iconRelative);
2117

2218
/** @type {import("@electron-forge/shared-types").ForgeConfig} */
2319
const config = {
2420
packagerConfig: {
25-
icon: getAppIcon(),
21+
icon,
2622
ignore: [
2723
/^\/(src)|(tools)|(.github)|(.vscode)/,
28-
/\/(.eslintrc.json)|(.gitignore)|(.gitattributes)|(electron.vite.config.ts)|(forge.config.cjs)|(tsconfig.json)|(bindl.config.js)|(bindl.config.js)|(README.md)$/,
24+
/\/(.gitignore)|(.gitattributes)|(electron.vite.config.ts)|(eslint.config.js)|(forge.config.js)|(prettier.config.js)|(renovate.json)|(tsconfig.json)|(README.md)$/,
2925
],
3026
// Prevents the app from showing up in the dock on macOS
3127
extendInfo: {
3228
LSUIElement: true,
3329
},
30+
// https://github.com/electron/forge/issues/2805#issuecomment-3193871995
31+
...(process.platform === "linux"
32+
? { executableName: "clipboard-sync" }
33+
: {}),
3434
},
3535
rebuildConfig: {},
3636
makers: [
3737
new MakerSquirrel({
3838
name: "clipboard_sync",
39-
setupIcon: getAppIcon(),
40-
iconUrl: getAppIcon(),
39+
setupIcon: icon,
40+
iconUrl: `https://raw.githubusercontent.com/felipecrs/clipboard-sync/refs/heads/master/${iconRelative}`,
4141
}),
4242
new MakerDMG({
43-
icon: getAppIcon(),
43+
icon,
44+
}),
45+
new MakerFlatpak({
46+
options: {
47+
id: "io.github.felipecrs.ClipboardSync",
48+
// @ts-expect-error - this is the correct way
49+
icon: {
50+
"512x512": icon,
51+
},
52+
categories: ["Utility"],
53+
sdk: "org.freedesktop.Sdk",
54+
runtime: "org.freedesktop.Platform",
55+
runtimeVersion: "24.08",
56+
base: "org.electronjs.Electron2.BaseApp",
57+
baseVersion: "24.08",
58+
finishArgs: [
59+
// Needed to monitor clipboard
60+
"--socket=system-bus",
61+
// Default permissions
62+
"--socket=x11",
63+
"--share=ipc",
64+
"--device=dri",
65+
"--socket=pulseaudio",
66+
"--filesystem=home",
67+
"--env=TMPDIR=/var/tmp",
68+
"--share=network",
69+
"--talk-name=org.freedesktop.Notifications",
70+
],
71+
// https://github.com/electron/forge/issues/2805
72+
modules: [
73+
{
74+
name: "zypak",
75+
sources: [
76+
{
77+
type: "git",
78+
url: "https://github.com/refi64/zypak",
79+
// https://github.com/refi64/zypak/releases
80+
tag: "v2024.01.17",
81+
},
82+
],
83+
},
84+
],
85+
},
4486
}),
4587
],
4688
};

0 commit comments

Comments
 (0)