Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -648,6 +650,7 @@ jobs:
# not (yet) wired into CI.
desktop:
needs: release
if: github.repository_owner == 'multica-ai'
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/(landing)/download/download-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DetectResult | null>(null);
Expand Down
5 changes: 3 additions & 2 deletions apps/web/features/landing/components/download/cli-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down
5 changes: 5 additions & 0 deletions apps/web/features/landing/release-repo.ts
Original file line number Diff line number Diff line change
@@ -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";
4 changes: 2 additions & 2 deletions apps/web/features/landing/utils/github-release.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RELEASE_REPO } from "../release-repo";
import {
parseReleaseAssets,
type DownloadAssets,
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand All @@ -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[]]) {
Expand Down
12 changes: 8 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 18 additions & 2 deletions server/internal/cli/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions server/internal/cli/update_release_repo_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
Loading