From 9943776a2b9de948beb5dc23e39d9996d40592da Mon Sep 17 00:00:00 2001 From: Rizel Scarlett Date: Sat, 2 Aug 2025 22:56:12 -0400 Subject: [PATCH 1/3] feat: add dynamic Linux install buttons with GitHub API - Replace hardcoded version URLs with GitHub API integration - Fetch latest release info dynamically on component mount - Add 1-hour localStorage caching to minimize API calls - Include fallback URLs for reliability if API fails - Auto-detect DEB and RPM files from release assets - Eliminates need for manual version updates in documentation --- .../components/LinuxDesktopInstallButtons.js | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/documentation/src/components/LinuxDesktopInstallButtons.js b/documentation/src/components/LinuxDesktopInstallButtons.js index 111f165e7600..e7e53095ee5c 100644 --- a/documentation/src/components/LinuxDesktopInstallButtons.js +++ b/documentation/src/components/LinuxDesktopInstallButtons.js @@ -1,20 +1,72 @@ import Link from "@docusaurus/Link"; import { IconDownload } from "@site/src/components/icons/download"; +import { useState, useEffect } from "react"; const LinuxDesktopInstallButtons = () => { + const [downloadUrls, setDownloadUrls] = useState({ + deb: "https://github.com/block/goose/releases/download/v1.1.4/goose_1.1.4_amd64.deb", + rpm: "https://github.com/block/goose/releases/download/v1.1.4/Goose-1.1.4-1.x86_64.rpm" + }); + + useEffect(() => { + const fetchLatestRelease = async () => { + try { + // Check cache first (1 hour expiry) + 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 + const cachedData = JSON.parse(cached); + setDownloadUrls(cachedData); + return; + } + + // 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 + 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()); + } + } catch (error) { + console.warn('Failed to fetch latest release, using fallback URLs:', error); + // Fallback URLs are already set in initial state + } + }; + + fetchLatestRelease(); + }, []); + return (

To download Goose Desktop for Linux, choose the buttons below:

DEB Package (Ubuntu/Debian) RPM Package (RHEL/Fedora) From 3eec0f550dc3e9553bf234541924af63dafd06b3 Mon Sep 17 00:00:00 2001 From: Rizel Scarlett Date: Sat, 2 Aug 2025 23:27:47 -0400 Subject: [PATCH 2/3] fix: update fallback URLs to use GitHub releases/latest page - Replace hardcoded version fallback URLs with generic releases/latest - Ensures fallback always points to latest release page even if API fails - Users can manually find and download correct files as backup --- documentation/src/components/LinuxDesktopInstallButtons.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/src/components/LinuxDesktopInstallButtons.js b/documentation/src/components/LinuxDesktopInstallButtons.js index e7e53095ee5c..fff1520c168e 100644 --- a/documentation/src/components/LinuxDesktopInstallButtons.js +++ b/documentation/src/components/LinuxDesktopInstallButtons.js @@ -4,8 +4,8 @@ import { useState, useEffect } from "react"; const LinuxDesktopInstallButtons = () => { const [downloadUrls, setDownloadUrls] = useState({ - deb: "https://github.com/block/goose/releases/download/v1.1.4/goose_1.1.4_amd64.deb", - rpm: "https://github.com/block/goose/releases/download/v1.1.4/Goose-1.1.4-1.x86_64.rpm" + deb: "https://github.com/block/goose/releases/latest", + rpm: "https://github.com/block/goose/releases/latest" }); useEffect(() => { From 26151bbad04d0e2f7bcf9930517200d020b73138 Mon Sep 17 00:00:00 2001 From: Rizel Scarlett Date: Sun, 3 Aug 2025 19:14:54 -0400 Subject: [PATCH 3/3] update based on comments --- .../src/components/LinuxDesktopInstallButtons.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/documentation/src/components/LinuxDesktopInstallButtons.js b/documentation/src/components/LinuxDesktopInstallButtons.js index fff1520c168e..2a7f335522a0 100644 --- a/documentation/src/components/LinuxDesktopInstallButtons.js +++ b/documentation/src/components/LinuxDesktopInstallButtons.js @@ -2,10 +2,12 @@ import Link from "@docusaurus/Link"; import { IconDownload } from "@site/src/components/icons/download"; import { useState, useEffect } from "react"; +const FALLBACK_URL = "https://github.com/block/goose/releases/latest"; + const LinuxDesktopInstallButtons = () => { const [downloadUrls, setDownloadUrls] = useState({ - deb: "https://github.com/block/goose/releases/latest", - rpm: "https://github.com/block/goose/releases/latest" + deb: FALLBACK_URL, + rpm: FALLBACK_URL }); useEffect(() => { @@ -18,8 +20,7 @@ const LinuxDesktopInstallButtons = () => { if (cached && cacheTime && (now - parseInt(cacheTime)) < 3600000) { // Use cached data if less than 1 hour old - const cachedData = JSON.parse(cached); - setDownloadUrls(cachedData); + setDownloadUrls(JSON.parse(cached)); return; }