diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a82d28fc8d7..9dd50056dfe6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,7 +112,7 @@ jobs: # `multica-ai/homebrew-tap` anyway. Without this guard, every fork's # tag push fails this job (401 against the upstream tap), which makes # downstream CI go red without affecting the actual artifact pipeline. - if: github.repository_owner == 'multica-ai' + if: github.repository_owner == 'multica-ai' || github.repository == 'Time-Machine-Lab/Stein-AI' runs-on: ubuntu-latest steps: - name: Checkout @@ -136,7 +136,9 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: version: "~> v2" - args: release --clean + # The Homebrew tap only exists upstream; the fork publishes CLI archives + # to its own GitHub Release and `multica update` reads them from there. + args: release --clean${{ github.repository_owner != 'multica-ai' && ' --skip=homebrew' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} @@ -648,6 +650,7 @@ jobs: # not (yet) wired into CI. desktop: needs: release + if: github.repository_owner == 'multica-ai' strategy: fail-fast: false matrix: diff --git a/.goreleaser.yml b/.goreleaser.yml index a34979a1a77f..f395f8a02937 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,6 +12,8 @@ builds: - -X main.version={{.Version}} - -X main.commit={{.ShortCommit}} - -X main.date={{.Date}} + # `multica update` reads releases from the repository that built the binary. + - -X github.com/multica-ai/multica/server/internal/cli.DefaultReleaseRepo={{ envOrDefault "GITHUB_REPOSITORY" "multica-ai/multica" }} env: - CGO_ENABLED=0 goos: diff --git a/apps/web/app/(landing)/download/download-client.tsx b/apps/web/app/(landing)/download/download-client.tsx index 763b89bfa8b7..9a3665246eba 100644 --- a/apps/web/app/(landing)/download/download-client.tsx +++ b/apps/web/app/(landing)/download/download-client.tsx @@ -13,10 +13,10 @@ import { detectOS, type DetectResult, } from "@/features/landing/utils/os-detect"; +import { RELEASE_REPO } from "@/features/landing/release-repo"; import type { LatestRelease } from "@/features/landing/utils/github-release"; -const ALL_RELEASES_URL = - "https://github.com/multica-ai/multica/releases"; +const ALL_RELEASES_URL = `https://github.com/${RELEASE_REPO}/releases`; export function DownloadClient({ release }: { release: LatestRelease }) { const [detected, setDetected] = useState(null); diff --git a/apps/web/features/landing/components/download/cli-section.tsx b/apps/web/features/landing/components/download/cli-section.tsx index b22811c44a58..352fb95b1ce2 100644 --- a/apps/web/features/landing/components/download/cli-section.tsx +++ b/apps/web/features/landing/components/download/cli-section.tsx @@ -4,9 +4,10 @@ import { useState } from "react"; import { Check, Copy, Terminal } from "lucide-react"; import { copyText } from "@multica/ui/lib/clipboard"; import { useLocale } from "../../i18n"; +import { RELEASE_REPO } from "../../release-repo"; -const INSTALL_CMD = - "curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash"; +// The script defaults to upstream releases, so point it at ours explicitly. +const INSTALL_CMD = `curl -fsSL https://raw.githubusercontent.com/${RELEASE_REPO}/main/scripts/install.sh | MULTICA_RELEASE_REPO=${RELEASE_REPO} bash`; const SETUP_CMD = "multica setup"; /** diff --git a/apps/web/features/landing/release-repo.ts b/apps/web/features/landing/release-repo.ts new file mode 100644 index 000000000000..8c8b02a07996 --- /dev/null +++ b/apps/web/features/landing/release-repo.ts @@ -0,0 +1,5 @@ +/** + * GitHub "owner/name" that CLI and desktop release assets are read from. + * Must match the repository whose Release workflow publishes the binaries. + */ +export const RELEASE_REPO = "Time-Machine-Lab/Stein-AI"; diff --git a/apps/web/features/landing/utils/github-release.ts b/apps/web/features/landing/utils/github-release.ts index 1def12f0b3f2..f0f1b41c155a 100644 --- a/apps/web/features/landing/utils/github-release.ts +++ b/apps/web/features/landing/utils/github-release.ts @@ -1,3 +1,4 @@ +import { RELEASE_REPO } from "../release-repo"; import { parseReleaseAssets, type DownloadAssets, @@ -30,8 +31,7 @@ export interface LatestRelease { assets: DownloadAssets; } -const GITHUB_RELEASES_URL = - "https://api.github.com/repos/multica-ai/multica/releases?per_page=2"; +const GITHUB_RELEASES_URL = `https://api.github.com/repos/${RELEASE_REPO}/releases?per_page=2`; const REVALIDATE_SECONDS = 300; diff --git a/scripts/install.ps1 b/scripts/install.ps1 index b59e15e2777c..ba5e7aed458a 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -14,6 +14,9 @@ $ErrorActionPreference = "Stop" # --------------------------------------------------------------------------- $RepoUrl = "https://github.com/multica-ai/multica.git" $RepoWebUrl = "https://github.com/multica-ai/multica" +# GitHub "owner/name" that CLI release archives are downloaded from; a fork sets +# MULTICA_RELEASE_REPO to use its own releases. +$ReleaseRepo = if ($env:MULTICA_RELEASE_REPO) { $env:MULTICA_RELEASE_REPO } else { "multica-ai/multica" } $DefaultInstallDir = Join-Path $env:USERPROFILE ".multica\server" $InstallDir = if ($env:MULTICA_INSTALL_DIR) { $env:MULTICA_INSTALL_DIR } else { $DefaultInstallDir } @@ -86,7 +89,7 @@ function Get-ComposePublishedPort { function Get-LatestVersion { try { - $release = Invoke-RestMethod -Uri "https://api.github.com/repos/multica-ai/multica/releases/latest" -ErrorAction Stop + $release = Invoke-RestMethod -Uri "https://api.github.com/repos/$ReleaseRepo/releases/latest" -ErrorAction Stop return $release.tag_name } catch { return $null @@ -247,7 +250,7 @@ function Install-CliBinary { } $version = $latest.TrimStart('v') - $url = "https://github.com/multica-ai/multica/releases/download/$latest/multica-cli-$version-windows-$arch.zip" + $url = "https://github.com/$ReleaseRepo/releases/download/$latest/multica-cli-$version-windows-$arch.zip" $tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) "multica-install" if (Test-Path $tmpDir) { Remove-Item $tmpDir -Recurse -Force } @@ -262,7 +265,7 @@ function Install-CliBinary { } # Verify SHA256 checksum - $checksumUrl = "https://github.com/multica-ai/multica/releases/download/$latest/checksums.txt" + $checksumUrl = "https://github.com/$ReleaseRepo/releases/download/$latest/checksums.txt" try { $checksums = Invoke-WebRequest -Uri $checksumUrl -UseBasicParsing -ErrorAction Stop $checksumContent = if ($checksums.Content -is [byte[]]) { diff --git a/scripts/install.sh b/scripts/install.sh index 254d9c3314e4..546927b15e7c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -18,6 +18,10 @@ REPO_URL="https://github.com/multica-ai/multica.git" REPO_WEB_URL="https://github.com/multica-ai/multica" # without .git, for GitHub web APIs INSTALL_DIR="${MULTICA_INSTALL_DIR:-$HOME/.multica/server}" BREW_PACKAGE="multica-ai/tap/multica" +# GitHub "owner/name" that CLI release archives are downloaded from. A fork sets +# MULTICA_RELEASE_REPO to use its own releases; Homebrew is then skipped because +# the tap only carries upstream builds. +RELEASE_REPO="${MULTICA_RELEASE_REPO:-multica-ai/multica}" # Host ports Compose reported after `up -d`; set by setup_server and reused by # the summary so the health check and the printed URLs cannot diverge. @@ -149,13 +153,13 @@ install_cli_binary() { # Get latest release tag local latest - latest=$(curl -sI "$REPO_WEB_URL/releases/latest" 2>/dev/null | grep -i '^location:' | sed 's/.*tag\///' | tr -d '\r\n' || true) + latest=$(curl -sI "https://github.com/$RELEASE_REPO/releases/latest" 2>/dev/null | grep -i '^location:' | sed 's/.*tag\///' | tr -d '\r\n' || true) if [ -z "$latest" ]; then fail "Could not determine latest release. Check your network connection." fi local version="${latest#v}" - local url="https://github.com/multica-ai/multica/releases/download/${latest}/multica-cli-${version}-${OS}-${ARCH}.tar.gz" + local url="https://github.com/$RELEASE_REPO/releases/download/${latest}/multica-cli-${version}-${OS}-${ARCH}.tar.gz" local tmp_dir tmp_dir=$(mktemp -d) @@ -284,7 +288,7 @@ install_cli() { fi info "Multica CLI $current_ver installed, latest is $latest_ver — upgrading..." - if command_exists brew && brew list "$BREW_PACKAGE" >/dev/null 2>&1; then + if command_exists brew && [ -z "${MULTICA_RELEASE_REPO:-}" ] && brew list "$BREW_PACKAGE" >/dev/null 2>&1; then upgrade_cli_brew else install_cli_binary @@ -296,7 +300,7 @@ install_cli() { return 0 fi - if command_exists brew; then + if command_exists brew && [ -z "${MULTICA_RELEASE_REPO:-}" ]; then install_cli_brew || install_cli_binary else install_cli_binary diff --git a/server/internal/cli/update.go b/server/internal/cli/update.go index 4c57997096df..b4150bbcfde7 100644 --- a/server/internal/cli/update.go +++ b/server/internal/cli/update.go @@ -224,9 +224,25 @@ func verifyAssetSHA256(data []byte, expectedHex, assetName string) error { return nil } +// DefaultReleaseRepo is the GitHub "owner/name" that `multica update` reads +// releases from. Release builds override it via ldflags so a fork's binaries +// update from the fork; MULTICA_RELEASE_REPO overrides it at runtime. +var DefaultReleaseRepo = "multica-ai/multica" + +func releaseRepo() string { + if repo := strings.TrimSpace(os.Getenv("MULTICA_RELEASE_REPO")); repo != "" { + return repo + } + return DefaultReleaseRepo +} + +func releaseAPIURL(path string) string { + return "https://api.github.com/repos/" + releaseRepo() + "/" + path +} + func fetchReleaseByTag(tag string) (*GitHubRelease, error) { client := &http.Client{Timeout: 10 * time.Second} - req, err := http.NewRequest(http.MethodGet, "https://api.github.com/repos/multica-ai/multica/releases/tags/"+tag, nil) + req, err := http.NewRequest(http.MethodGet, releaseAPIURL("releases/tags/"+tag), nil) if err != nil { return nil, err } @@ -252,7 +268,7 @@ func fetchReleaseByTag(tag string) (*GitHubRelease, error) { // FetchLatestRelease fetches the latest release tag from the multica GitHub repo. func FetchLatestRelease() (*GitHubRelease, error) { client := &http.Client{Timeout: 10 * time.Second} - req, err := http.NewRequest(http.MethodGet, "https://api.github.com/repos/multica-ai/multica/releases/latest", nil) + req, err := http.NewRequest(http.MethodGet, releaseAPIURL("releases/latest"), nil) if err != nil { return nil, err } diff --git a/server/internal/cli/update_release_repo_test.go b/server/internal/cli/update_release_repo_test.go new file mode 100644 index 000000000000..2bae39e85aa5 --- /dev/null +++ b/server/internal/cli/update_release_repo_test.go @@ -0,0 +1,15 @@ +package cli + +import "testing" + +func TestReleaseAPIURLUsesConfiguredRepo(t *testing.T) { + t.Setenv("MULTICA_RELEASE_REPO", "") + if got, want := releaseAPIURL("releases/latest"), "https://api.github.com/repos/"+DefaultReleaseRepo+"/releases/latest"; got != want { + t.Fatalf("default: got %q, want %q", got, want) + } + + t.Setenv("MULTICA_RELEASE_REPO", " Time-Machine-Lab/Stein-AI ") + if got, want := releaseAPIURL("releases/tags/v0.1.2"), "https://api.github.com/repos/Time-Machine-Lab/Stein-AI/releases/tags/v0.1.2"; got != want { + t.Fatalf("override: got %q, want %q", got, want) + } +}