feat: add flatpak support for linux (#6387)

Signed-off-by: The-Best-Codes <bestcodes.official@gmail.com>
This commit is contained in:
BestCodes
2026-01-14 12:21:54 -06:00
committed by GitHub
parent eaa05f9636
commit 20b8cbd41b
10 changed files with 723 additions and 490 deletions
+22 -7
View File
@@ -21,7 +21,7 @@ name: "Bundle Desktop (Linux)"
jobs: jobs:
build-desktop-linux: build-desktop-linux:
name: Build Desktop (Linux) name: Build Desktop (Linux)
runs-on: ubuntu-latest runs-on: ubuntu-x86-16core-64gb
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -76,7 +76,14 @@ jobs:
rpm \ rpm \
fakeroot \ fakeroot \
dpkg-dev \ dpkg-dev \
protobuf-compiler protobuf-compiler \
flatpak \
flatpak-builder \
elfutils
- name: Setup Flatpak Runtimes
run: |
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
- name: Activate hermit and set CARGO_HOME - name: Activate hermit and set CARGO_HOME
run: | run: |
@@ -136,14 +143,14 @@ jobs:
run: | run: |
source ./bin/activate-hermit source ./bin/activate-hermit
cd ui/desktop cd ui/desktop
echo "Building Linux packages (.deb and .rpm)..." echo "Building Linux packages (.deb, .rpm, and .flatpak)..."
# Build both .deb and .rpm packages # Build all configured packages
npm run make -- --platform=linux --arch=x64 npm run make -- --platform=linux --arch=x64
echo "Build completed. Checking output..." echo "Build completed. Checking output..."
ls -la out/ ls -la out/
find out/ -name "*.deb" -o -name "*.rpm" | head -10 find out/ -name "*.deb" -o -name "*.rpm" -o -name "*.flatpak" | head -10
- name: List generated files - name: List generated files
run: | run: |
@@ -151,10 +158,10 @@ jobs:
find ui/desktop/out/ -type f | head -20 find ui/desktop/out/ -type f | head -20
echo "" echo ""
echo "=== Package files specifically ===" echo "=== Package files specifically ==="
find ui/desktop/out/ -name "*.deb" -o -name "*.rpm" find ui/desktop/out/ -name "*.deb" -o -name "*.rpm" -o -name "*.flatpak"
echo "" echo ""
echo "=== File sizes ===" echo "=== File sizes ==="
find ui/desktop/out/ -name "*.deb" -o -name "*.rpm" -exec ls -lh {} \; find ui/desktop/out/ -name "*.deb" -o -name "*.rpm" -o -name "*.flatpak" -exec ls -lh {} \;
- name: Upload .deb package - name: Upload .deb package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@@ -170,6 +177,13 @@ jobs:
path: ui/desktop/out/make/rpm/x64/*.rpm path: ui/desktop/out/make/rpm/x64/*.rpm
if-no-files-found: error if-no-files-found: error
- name: Upload .flatpak package
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: Goose-linux-x64-flatpak
path: ui/desktop/out/make/flatpak/**/*.flatpak
if-no-files-found: error
- name: Upload combined Linux packages - name: Upload combined Linux packages
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with: with:
@@ -177,4 +191,5 @@ jobs:
path: | path: |
ui/desktop/out/make/deb/x64/*.deb ui/desktop/out/make/deb/x64/*.deb
ui/desktop/out/make/rpm/x64/*.rpm ui/desktop/out/make/rpm/x64/*.rpm
ui/desktop/out/make/flatpak/**/*.flatpak
if-no-files-found: error if-no-files-found: error
+1
View File
@@ -119,6 +119,7 @@ jobs:
Goose*.zip Goose*.zip
*.deb *.deb
*.rpm *.rpm
*.flatpak
download_cli.sh download_cli.sh
allowUpdates: true allowUpdates: true
omitBody: true omitBody: true
+1
View File
@@ -121,6 +121,7 @@ jobs:
Goose*.zip Goose*.zip
*.deb *.deb
*.rpm *.rpm
*.flatpak
download_cli.sh download_cli.sh
allowUpdates: true allowUpdates: true
omitBody: true omitBody: true
+2
View File
@@ -109,6 +109,7 @@ jobs:
Goose*.zip Goose*.zip
*.deb *.deb
*.rpm *.rpm
*.flatpak
download_cli.sh download_cli.sh
allowUpdates: true allowUpdates: true
omitBody: true omitBody: true
@@ -127,6 +128,7 @@ jobs:
Goose*.zip Goose*.zip
*.deb *.deb
*.rpm *.rpm
*.flatpak
download_cli.sh download_cli.sh
allowUpdates: true allowUpdates: true
omitBody: true omitBody: true
+17 -2
View File
@@ -138,8 +138,23 @@ If you see "Could not find goosed binary", ensure you've:
- The RPM maker is disabled by default as it's not compatible with Arch-based systems - The RPM maker is disabled by default as it's not compatible with Arch-based systems
- Use the ZIP distribution method for maximum compatibility - Use the ZIP distribution method for maximum compatibility
#### Flatpak/Snap #### Flatpak
Building as Flatpak or Snap packages is not currently supported but may be added in the future. Flatpak builds are supported via CI. To build locally:
```bash
# Install flatpak and flatpak-builder
sudo apt install flatpak flatpak-builder
# Add Flathub remote
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# Build with Electron Forge
npm run make -- --targets=@electron-forge/maker-flatpak
```
Output: `out/make/flatpak/x86_64/*.flatpak`
#### Snap
Building as Snap packages is not currently supported but may be added in the future.
## Development Workflow ## Development Workflow
@@ -7,7 +7,8 @@ const FALLBACK_URL = "https://github.com/block/goose/releases/latest";
const LinuxDesktopInstallButtons = () => { const LinuxDesktopInstallButtons = () => {
const [downloadUrls, setDownloadUrls] = useState({ const [downloadUrls, setDownloadUrls] = useState({
deb: FALLBACK_URL, deb: FALLBACK_URL,
rpm: FALLBACK_URL rpm: FALLBACK_URL,
flatpak: FALLBACK_URL
}); });
useEffect(() => { useEffect(() => {
@@ -17,7 +18,7 @@ const LinuxDesktopInstallButtons = () => {
const cached = localStorage.getItem('goose-release-cache'); const cached = localStorage.getItem('goose-release-cache');
const cacheTime = localStorage.getItem('goose-release-cache-time'); const cacheTime = localStorage.getItem('goose-release-cache-time');
const now = Date.now(); const now = Date.now();
if (cached && cacheTime && (now - parseInt(cacheTime)) < 3600000) { if (cached && cacheTime && (now - parseInt(cacheTime)) < 3600000) {
// Use cached data if less than 1 hour old // Use cached data if less than 1 hour old
setDownloadUrls(JSON.parse(cached)); setDownloadUrls(JSON.parse(cached));
@@ -27,25 +28,25 @@ const LinuxDesktopInstallButtons = () => {
// Fetch latest release from GitHub API // Fetch latest release from GitHub API
const response = await fetch('https://api.github.com/repos/block/goose/releases/latest'); const response = await fetch('https://api.github.com/repos/block/goose/releases/latest');
if (!response.ok) throw new Error('API request failed'); if (!response.ok) throw new Error('API request failed');
const release = await response.json(); const release = await response.json();
const assets = release.assets || []; const assets = release.assets || [];
// Find DEB and RPM files // Find DEB, RPM, and Flatpak files
const debAsset = assets.find(asset => asset.name.includes('.deb') && asset.name.includes('amd64')); const debAsset = assets.find(asset => asset.name.includes('.deb') && asset.name.includes('amd64'));
const rpmAsset = assets.find(asset => asset.name.includes('.rpm') && asset.name.includes('x86_64')); const rpmAsset = assets.find(asset => asset.name.includes('.rpm') && asset.name.includes('x86_64'));
const flatpakAsset = assets.find(asset => asset.name.endsWith('.flatpak'));
if (debAsset && rpmAsset) {
const newUrls = { const newUrls = {
deb: debAsset.browser_download_url, deb: debAsset?.browser_download_url || FALLBACK_URL,
rpm: rpmAsset.browser_download_url rpm: rpmAsset?.browser_download_url || FALLBACK_URL,
}; flatpak: flatpakAsset?.browser_download_url || FALLBACK_URL
};
// Update state and cache
setDownloadUrls(newUrls); // Update state and cache
localStorage.setItem('goose-release-cache', JSON.stringify(newUrls)); setDownloadUrls(newUrls);
localStorage.setItem('goose-release-cache-time', now.toString()); localStorage.setItem('goose-release-cache', JSON.stringify(newUrls));
} localStorage.setItem('goose-release-cache-time', now.toString());
} catch (error) { } catch (error) {
console.warn('Failed to fetch latest release, using fallback URLs:', error); console.warn('Failed to fetch latest release, using fallback URLs:', error);
// Fallback URLs are already set in initial state // Fallback URLs are already set in initial state
@@ -71,9 +72,15 @@ const LinuxDesktopInstallButtons = () => {
> >
<IconDownload /> RPM Package (RHEL/Fedora) <IconDownload /> RPM Package (RHEL/Fedora)
</Link> </Link>
<Link
className="button button--primary button--lg"
to={downloadUrls.flatpak}
>
<IconDownload /> Flatpak (Universal)
</Link>
</div> </div>
</div> </div>
); );
}; };
export default LinuxDesktopInstallButtons; export default LinuxDesktopInstallButtons;
+4
View File
@@ -75,11 +75,15 @@ npm run make -- --targets=@electron-forge/maker-zip
# For DEB package (Debian/Ubuntu) # For DEB package (Debian/Ubuntu)
npm run make -- --targets=@electron-forge/maker-deb npm run make -- --targets=@electron-forge/maker-deb
# For Flatpak (requires flatpak and flatpak-builder)
npm run make -- --targets=@electron-forge/maker-flatpak
``` ```
The built application will be available in: The built application will be available in:
- ZIP: `out/make/zip/linux/x64/goose-linux-x64-{version}.zip` - ZIP: `out/make/zip/linux/x64/goose-linux-x64-{version}.zip`
- DEB: `out/make/deb/x64/goose_{version}_amd64.deb` - DEB: `out/make/deb/x64/goose_{version}_amd64.deb`
- Flatpak: `out/make/flatpak/x86_64/*.flatpak`
- Executable: `out/goose-linux-x64/goose` - Executable: `out/goose-linux-x64/goose`
### Windows ### Windows
+39
View File
@@ -93,6 +93,45 @@ module.exports = {
}, },
}, },
}, },
{
name: '@electron-forge/maker-flatpak',
config: {
options: {
categories: ['Development'],
icon: 'src/images/icon.png',
homepage: 'https://block.github.io/goose/',
runtimeVersion: '25.08',
baseVersion: '25.08',
bin: 'Goose',
modules: [
{
name: 'libbz2-shim',
buildsystem: 'simple',
'build-commands': [
// Create the lib directory in the app bundle
'mkdir -p /app/lib',
// Point to the actual library in the 25.08 runtime
// We use a wildcard to handle multi-arch paths (x86_64-linux-gnu, etc)
'ln -s $(find /usr/lib -name "libbz2.so.1" | head -n 1) /app/lib/libbz2.so.1.0'
]
}
],
finishArgs: [
'--share=ipc',
'--socket=x11',
'--socket=wayland',
'--device=dri',
'--share=network',
'--filesystem=home',
'--talk-name=org.freedesktop.Notifications',
'--socket=session-bus',
'--socket=system-bus',
// This ensures the app looks in our shim folder first
'--env=LD_LIBRARY_PATH=/app/lib'
],
},
},
},
], ],
plugins: [ plugins: [
{ {
+611 -463
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -94,6 +94,7 @@
"devDependencies": { "devDependencies": {
"@electron-forge/cli": "^7.10.2", "@electron-forge/cli": "^7.10.2",
"@electron-forge/maker-deb": "^7.10.2", "@electron-forge/maker-deb": "^7.10.2",
"@electron-forge/maker-flatpak": "^7.10.2",
"@electron-forge/maker-rpm": "^7.10.2", "@electron-forge/maker-rpm": "^7.10.2",
"@electron-forge/maker-squirrel": "^7.10.2", "@electron-forge/maker-squirrel": "^7.10.2",
"@electron-forge/maker-zip": "^7.10.2", "@electron-forge/maker-zip": "^7.10.2",