mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 19:59:20 +02:00
Compare commits
4 Commits
v0.1.26
...
feat/cli-v
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
509faab19f | ||
|
|
29f7959db7 | ||
|
|
bd1a7eb680 | ||
|
|
3198972d15 |
@@ -11,6 +11,7 @@ builds:
|
||||
- -s -w
|
||||
- -X main.version={{.Version}}
|
||||
- -X main.commit={{.ShortCommit}}
|
||||
- -X main.date={{.Date}}
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
|
||||
3
Makefile
3
Makefile
@@ -190,10 +190,11 @@ multica:
|
||||
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
build:
|
||||
cd server && go build -o bin/server ./cmd/server
|
||||
cd server && go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" -o bin/multica ./cmd/multica
|
||||
cd server && go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)" -o bin/multica ./cmd/multica
|
||||
cd server && go build -o bin/migrate ./cmd/migrate
|
||||
|
||||
test:
|
||||
|
||||
@@ -123,6 +123,24 @@ make selfhost-stop
|
||||
multica daemon stop
|
||||
```
|
||||
|
||||
## Switching to Multica Cloud
|
||||
|
||||
If you've been self-hosting and want to switch your CLI to [Multica Cloud](https://multica.ai):
|
||||
|
||||
```bash
|
||||
multica config set server_url https://api.multica.ai
|
||||
multica config set app_url https://multica.ai
|
||||
multica login
|
||||
```
|
||||
|
||||
Or re-run the install script without `--local` — it will reconfigure the CLI automatically:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
> Your local Docker services are unaffected. Stop them separately if you no longer need them.
|
||||
|
||||
## Rebuilding After Updates
|
||||
|
||||
```bash
|
||||
|
||||
@@ -118,6 +118,26 @@ make selfhost-stop
|
||||
multica daemon stop
|
||||
```
|
||||
|
||||
## Switching to Multica Cloud
|
||||
|
||||
If you've been self-hosting and want to switch your CLI to [Multica Cloud](https://multica.ai):
|
||||
|
||||
```bash
|
||||
multica config set server_url https://api.multica.ai
|
||||
multica config set app_url https://multica.ai
|
||||
multica login
|
||||
```
|
||||
|
||||
Or re-run the install script without `--local` — it will reconfigure the CLI automatically:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
<Callout>
|
||||
Your local Docker services are unaffected. Stop them separately if you no longer need them.
|
||||
</Callout>
|
||||
|
||||
## Rebuilding After Updates
|
||||
|
||||
```bash
|
||||
|
||||
@@ -13,6 +13,7 @@ set -euo pipefail
|
||||
# Configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
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"
|
||||
|
||||
@@ -62,10 +63,16 @@ install_cli_brew() {
|
||||
if ! brew tap multica-ai/tap 2>/dev/null; then
|
||||
fail "Failed to add Homebrew tap. Check your network connection."
|
||||
fi
|
||||
# brew install exits non-zero if already installed on older Homebrew versions
|
||||
if ! brew install multica 2>/dev/null; then
|
||||
fail "Failed to install multica via Homebrew."
|
||||
if brew list multica >/dev/null 2>&1; then
|
||||
ok "Multica CLI already installed via Homebrew"
|
||||
else
|
||||
fail "Failed to install multica via Homebrew."
|
||||
fi
|
||||
else
|
||||
ok "Multica CLI installed via Homebrew"
|
||||
fi
|
||||
ok "Multica CLI installed via Homebrew"
|
||||
}
|
||||
|
||||
install_cli_binary() {
|
||||
@@ -73,7 +80,7 @@ install_cli_binary() {
|
||||
|
||||
# Get latest release tag
|
||||
local latest
|
||||
latest=$(curl -sI "$REPO_URL/releases/latest" | grep -i '^location:' | sed 's/.*tag\///' | tr -d '\r\n')
|
||||
latest=$(curl -sI "$REPO_WEB_URL/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
|
||||
@@ -122,12 +129,50 @@ add_to_path() {
|
||||
done
|
||||
}
|
||||
|
||||
get_latest_version() {
|
||||
# grep exits 1 when no match; use `|| true` to avoid triggering pipefail
|
||||
curl -sI "$REPO_WEB_URL/releases/latest" 2>/dev/null | grep -i '^location:' | sed 's/.*tag\///' | tr -d '\r\n' || true
|
||||
}
|
||||
|
||||
upgrade_cli_brew() {
|
||||
info "Upgrading Multica CLI via Homebrew..."
|
||||
brew update 2>/dev/null || true
|
||||
if brew upgrade multica 2>/dev/null; then
|
||||
ok "Multica CLI upgraded via Homebrew"
|
||||
else
|
||||
# brew upgrade exits non-zero if already up to date
|
||||
ok "Multica CLI is already the latest version"
|
||||
fi
|
||||
}
|
||||
|
||||
install_cli() {
|
||||
# Skip if already installed
|
||||
if command_exists multica; then
|
||||
local ver
|
||||
ver=$(multica version 2>/dev/null || echo "unknown")
|
||||
ok "Multica CLI already installed ($ver)"
|
||||
local current_ver
|
||||
# `multica version` outputs "multica v0.1.13 (commit: abc1234)" — extract just the version
|
||||
current_ver=$(multica version 2>/dev/null | awk '{print $2}' || echo "unknown")
|
||||
|
||||
local latest_ver
|
||||
latest_ver=$(get_latest_version)
|
||||
|
||||
# Normalize: strip leading 'v' for comparison
|
||||
local current_cmp="${current_ver#v}"
|
||||
local latest_cmp="${latest_ver#v}"
|
||||
|
||||
if [ -z "$latest_ver" ] || [ "$current_cmp" = "$latest_cmp" ]; then
|
||||
ok "Multica CLI is up to date ($current_ver)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
info "Multica CLI $current_ver installed, latest is $latest_ver — upgrading..."
|
||||
if command_exists brew && brew list multica >/dev/null 2>&1; then
|
||||
upgrade_cli_brew
|
||||
else
|
||||
install_cli_binary
|
||||
fi
|
||||
|
||||
local new_ver
|
||||
new_ver=$(multica version 2>/dev/null | awk '{print $2}' || echo "unknown")
|
||||
ok "Multica CLI upgraded ($current_ver → $new_ver)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -181,6 +226,11 @@ setup_server() {
|
||||
if ! command_exists git; then
|
||||
fail "Git is not installed. Please install git and re-run."
|
||||
fi
|
||||
# Remove leftover directory from a previously interrupted clone
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
warn "Removing incomplete installation at $INSTALL_DIR..."
|
||||
rm -rf "$INSTALL_DIR"
|
||||
fi
|
||||
mkdir -p "$(dirname "$INSTALL_DIR")"
|
||||
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
|
||||
@@ -17,7 +17,7 @@ var updateCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func runUpdate(_ *cobra.Command, _ []string) error {
|
||||
fmt.Fprintf(os.Stderr, "Current version: %s (commit: %s)\n", version, commit)
|
||||
fmt.Fprintf(os.Stderr, "Current version: %s (commit: %s, built: %s)\n", version, commit, date)
|
||||
|
||||
// Check latest version from GitHub.
|
||||
latest, err := cli.FetchLatestRelease()
|
||||
|
||||
@@ -1,15 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
versionCmd.Flags().String("output", "text", "Output format: text or json")
|
||||
}
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version information",
|
||||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Printf("multica %s (commit: %s)\n", version, commit)
|
||||
},
|
||||
RunE: runVersion,
|
||||
}
|
||||
|
||||
func runVersion(cmd *cobra.Command, _ []string) error {
|
||||
output, _ := cmd.Flags().GetString("output")
|
||||
|
||||
if output == "json" {
|
||||
info := map[string]string{
|
||||
"version": version,
|
||||
"commit": commit,
|
||||
"date": date,
|
||||
"go": runtime.Version(),
|
||||
"os": runtime.GOOS,
|
||||
"arch": runtime.GOARCH,
|
||||
}
|
||||
enc := json.NewEncoder(os.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(info)
|
||||
}
|
||||
|
||||
fmt.Printf("multica %s (commit: %s, built: %s)\n", version, commit, date)
|
||||
fmt.Printf("go: %s, os/arch: %s/%s\n", runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
var (
|
||||
version = "dev"
|
||||
commit = "unknown"
|
||||
date = "unknown"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
|
||||
Reference in New Issue
Block a user