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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 723 additions and 490 deletions

View file

@ -21,7 +21,7 @@ name: "Bundle Desktop (Linux)"
jobs:
build-desktop-linux:
name: Build Desktop (Linux)
runs-on: ubuntu-latest
runs-on: ubuntu-x86-16core-64gb
steps:
- name: Checkout repository
@ -76,7 +76,14 @@ jobs:
rpm \
fakeroot \
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
run: |
@ -136,14 +143,14 @@ jobs:
run: |
source ./bin/activate-hermit
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
echo "Build completed. Checking output..."
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
run: |
@ -151,10 +158,10 @@ jobs:
find ui/desktop/out/ -type f | head -20
echo ""
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 "=== 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
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@ -170,6 +177,13 @@ jobs:
path: ui/desktop/out/make/rpm/x64/*.rpm
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
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
@ -177,4 +191,5 @@ jobs:
path: |
ui/desktop/out/make/deb/x64/*.deb
ui/desktop/out/make/rpm/x64/*.rpm
ui/desktop/out/make/flatpak/**/*.flatpak
if-no-files-found: error

View file

@ -119,6 +119,7 @@ jobs:
Goose*.zip
*.deb
*.rpm
*.flatpak
download_cli.sh
allowUpdates: true
omitBody: true

View file

@ -121,6 +121,7 @@ jobs:
Goose*.zip
*.deb
*.rpm
*.flatpak
download_cli.sh
allowUpdates: true
omitBody: true

View file

@ -109,6 +109,7 @@ jobs:
Goose*.zip
*.deb
*.rpm
*.flatpak
download_cli.sh
allowUpdates: true
omitBody: true
@ -127,6 +128,7 @@ jobs:
Goose*.zip
*.deb
*.rpm
*.flatpak
download_cli.sh
allowUpdates: true
omitBody: true

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
- Use the ZIP distribution method for maximum compatibility
#### Flatpak/Snap
Building as Flatpak or Snap packages is not currently supported but may be added in the future.
#### Flatpak
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

View file

@ -7,7 +7,8 @@ const FALLBACK_URL = "https://github.com/block/goose/releases/latest";
const LinuxDesktopInstallButtons = () => {
const [downloadUrls, setDownloadUrls] = useState({
deb: FALLBACK_URL,
rpm: FALLBACK_URL
rpm: FALLBACK_URL,
flatpak: FALLBACK_URL
});
useEffect(() => {
@ -17,7 +18,7 @@ const LinuxDesktopInstallButtons = () => {
const cached = localStorage.getItem('goose-release-cache');
const cacheTime = localStorage.getItem('goose-release-cache-time');
const now = Date.now();
if (cached && cacheTime && (now - parseInt(cacheTime)) < 3600000) {
// Use cached data if less than 1 hour old
setDownloadUrls(JSON.parse(cached));
@ -27,25 +28,25 @@ const LinuxDesktopInstallButtons = () => {
// Fetch latest release from GitHub API
const response = await fetch('https://api.github.com/repos/block/goose/releases/latest');
if (!response.ok) throw new Error('API request failed');
const release = await response.json();
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 rpmAsset = assets.find(asset => asset.name.includes('.rpm') && asset.name.includes('x86_64'));
if (debAsset && rpmAsset) {
const newUrls = {
deb: debAsset.browser_download_url,
rpm: rpmAsset.browser_download_url
};
// Update state and cache
setDownloadUrls(newUrls);
localStorage.setItem('goose-release-cache', JSON.stringify(newUrls));
localStorage.setItem('goose-release-cache-time', now.toString());
}
const flatpakAsset = assets.find(asset => asset.name.endsWith('.flatpak'));
const newUrls = {
deb: debAsset?.browser_download_url || FALLBACK_URL,
rpm: rpmAsset?.browser_download_url || FALLBACK_URL,
flatpak: flatpakAsset?.browser_download_url || FALLBACK_URL
};
// Update state and cache
setDownloadUrls(newUrls);
localStorage.setItem('goose-release-cache', JSON.stringify(newUrls));
localStorage.setItem('goose-release-cache-time', now.toString());
} catch (error) {
console.warn('Failed to fetch latest release, using fallback URLs:', error);
// Fallback URLs are already set in initial state
@ -71,9 +72,15 @@ const LinuxDesktopInstallButtons = () => {
>
<IconDownload /> RPM Package (RHEL/Fedora)
</Link>
<Link
className="button button--primary button--lg"
to={downloadUrls.flatpak}
>
<IconDownload /> Flatpak (Universal)
</Link>
</div>
</div>
);
};
export default LinuxDesktopInstallButtons;
export default LinuxDesktopInstallButtons;

View file

@ -75,11 +75,15 @@ npm run make -- --targets=@electron-forge/maker-zip
# For DEB package (Debian/Ubuntu)
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:
- ZIP: `out/make/zip/linux/x64/goose-linux-x64-{version}.zip`
- DEB: `out/make/deb/x64/goose_{version}_amd64.deb`
- Flatpak: `out/make/flatpak/x86_64/*.flatpak`
- Executable: `out/goose-linux-x64/goose`
### Windows

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: [
{

File diff suppressed because it is too large Load diff

View file

@ -94,6 +94,7 @@
"devDependencies": {
"@electron-forge/cli": "^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-squirrel": "^7.10.2",
"@electron-forge/maker-zip": "^7.10.2",