From a49b59e403b7a2db12a6568d7294790150df994b Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 29 Mar 2026 19:46:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=80=E9=94=AE=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 116 ++++++++++++++++++++++++++++++- README.md | 79 ++++++++++++++++----- docs/readme/README.ar.md | 79 ++++++++++++++++----- docs/readme/README.de.md | 90 +++++++++++++++++++----- docs/readme/README.es.md | 90 +++++++++++++++++++----- docs/readme/README.fr.md | 90 +++++++++++++++++++----- docs/readme/README.ja.md | 81 +++++++++++++++++----- docs/readme/README.ko.md | 81 +++++++++++++++++----- docs/readme/README.pt.md | 79 ++++++++++++++++----- docs/readme/README.zh-CN.md | 79 ++++++++++++++++----- docs/readme/README.zh-TW.md | 79 ++++++++++++++++----- install.ps1 | 90 ++++++++++++++++++++++++ install.sh | 126 ++++++++++++++++++++++++++++++++++ 13 files changed, 996 insertions(+), 163 deletions(-) create mode 100644 install.ps1 create mode 100755 install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3bb3836..c3dda50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: outputs: release_id: ${{ steps.release.outputs.release_id }} release_url: ${{ steps.release.outputs.release_url }} + upload_url: ${{ steps.release.outputs.upload_url }} prerelease: ${{ steps.meta.outputs.prerelease }} release_body: ${{ steps.release.outputs.release_body }} steps: @@ -161,6 +162,7 @@ jobs: core.setOutput("release_id", String(release.id)); core.setOutput("release_url", release.html_url); + core.setOutput("upload_url", release.upload_url); core.setOutput("release_body", releaseBody); build-tauri: @@ -332,6 +334,117 @@ jobs: includeUpdaterJson: true retryAttempts: 2 + build-server: + needs: create-draft-release + name: Server ${{ matrix.name }} + permissions: + contents: write + strategy: + fail-fast: false + matrix: + include: + - name: "Linux x64" + runner: "ubuntu-22.04" + target: "x86_64-unknown-linux-gnu" + artifact: "codeg-server-linux-x64" + - name: "Linux arm64" + runner: "ubuntu-22.04" + target: "aarch64-unknown-linux-gnu" + artifact: "codeg-server-linux-arm64" + - name: "macOS x64" + runner: "macos-latest" + target: "x86_64-apple-darwin" + artifact: "codeg-server-darwin-x64" + - name: "macOS arm64" + runner: "macos-latest" + target: "aarch64-apple-darwin" + artifact: "codeg-server-darwin-arm64" + - name: "Windows x64" + runner: "windows-2022" + target: "x86_64-pc-windows-msvc" + artifact: "codeg-server-windows-x64" + runs-on: ${{ matrix.runner }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: "./src-tauri -> target" + shared-key: server-${{ matrix.target }} + + - name: Install Linux arm64 cross compiler + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + + - name: Build frontend + run: | + pnpm install --frozen-lockfile + pnpm build + + - name: Build server binary + working-directory: src-tauri + run: cargo build --release --bin codeg-server --no-default-features --target ${{ matrix.target }} + + - name: Package (Unix) + if: runner.os != 'Windows' + run: | + mkdir -p dist/${{ matrix.artifact }} + cp src-tauri/target/${{ matrix.target }}/release/codeg-server dist/${{ matrix.artifact }}/ + cp -r out dist/${{ matrix.artifact }}/web + cd dist && tar czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }} + + - name: Package (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path dist/${{ matrix.artifact }} + Copy-Item src-tauri/target/${{ matrix.target }}/release/codeg-server.exe dist/${{ matrix.artifact }}/ + Copy-Item -Recurse out dist/${{ matrix.artifact }}/web + Compress-Archive -Path dist/${{ matrix.artifact }} -DestinationPath dist/${{ matrix.artifact }}.zip + + - name: Upload to release (Unix) + if: runner.os != 'Windows' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-draft-release.outputs.upload_url }} + asset_path: dist/${{ matrix.artifact }}.tar.gz + asset_name: ${{ matrix.artifact }}.tar.gz + asset_content_type: application/gzip + + - name: Upload to release (Windows) + if: runner.os == 'Windows' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-draft-release.outputs.upload_url }} + asset_path: dist/${{ matrix.artifact }}.zip + asset_name: ${{ matrix.artifact }}.zip + asset_content_type: application/zip + build-docker: needs: create-draft-release name: Build Docker image @@ -383,7 +496,8 @@ jobs: needs: - create-draft-release - build-tauri - if: ${{ needs.build-tauri.result == 'success' }} + - build-server + if: ${{ needs.build-tauri.result == 'success' && needs.build-server.result == 'success' }} runs-on: ubuntu-22.04 permissions: contents: write diff --git a/README.md b/README.md index 406545d..77d6d57 100644 --- a/README.md +++ b/README.md @@ -157,17 +157,75 @@ cargo build Codeg can run as a standalone web server without a desktop environment. -#### Option 1: Direct binary +#### Option 1: One-line install (Linux / macOS) ```bash -# Build the server binary +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +Install a specific version or to a custom directory: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +Then run: + +```bash +codeg-server +``` + +#### Option 2: One-line install (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +Or install a specific version: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### Option 3: Download from GitHub Releases + +Pre-built binaries (with bundled web assets) are available on the [Releases](https://github.com/xintaofei/codeg/releases) page: + +| Platform | File | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# Example: download, extract, and run +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### Option 4: Docker + +```bash +docker compose up -d + +# Or run directly +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### Option 5: Build from source + +```bash +pnpm install && pnpm build # build frontend cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# Run it -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### Configuration + Environment variables: | Variable | Default | Description | @@ -178,17 +236,6 @@ Environment variables: | `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite database directory | | `CODEG_STATIC_DIR` | `./web` or `./out` | Next.js static export directory | -#### Option 2: Docker - -```bash -# Build and run -docker compose up -d - -# Or build manually -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` - ## Architecture ```text diff --git a/docs/readme/README.ar.md b/docs/readme/README.ar.md index 4aab258..0dd3d02 100644 --- a/docs/readme/README.ar.md +++ b/docs/readme/README.ar.md @@ -156,17 +156,75 @@ cargo build يمكن تشغيل Codeg كخادم ويب مستقل بدون بيئة سطح مكتب. -#### الخيار 1: الملف التنفيذي المباشر +#### الخيار 1: التثبيت بسطر واحد (Linux / macOS) ```bash -# بناء الملف التنفيذي للخادم +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +تثبيت إصدار محدد أو في دليل مخصص: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +ثم التشغيل: + +```bash +codeg-server +``` + +#### الخيار 2: التثبيت بسطر واحد (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +أو تثبيت إصدار محدد: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### الخيار 3: التنزيل من GitHub Releases + +الملفات التنفيذية المُعدّة مسبقًا (مع موارد الويب المضمّنة) متاحة في صفحة [Releases](https://github.com/xintaofei/codeg/releases): + +| المنصة | الملف | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# مثال: التنزيل والاستخراج والتشغيل +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### الخيار 4: Docker + +```bash +docker compose up -d + +# أو التشغيل مباشرة +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### الخيار 5: البناء من المصدر + +```bash +pnpm install && pnpm build # بناء الواجهة الأمامية cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# التشغيل -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### التكوين + متغيرات البيئة: | المتغير | الافتراضي | الوصف | @@ -177,17 +235,6 @@ CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server | `CODEG_DATA_DIR` | `~/.local/share/codeg` | دليل قاعدة بيانات SQLite | | `CODEG_STATIC_DIR` | `./web` أو `./out` | دليل التصدير الثابت لـ Next.js | -#### الخيار 2: Docker - -```bash -# البناء والتشغيل -docker compose up -d - -# أو البناء يدويًا -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` - ## الهندسة المعمارية ```text diff --git a/docs/readme/README.de.md b/docs/readme/README.de.md index 342d5a3..0fc5218 100644 --- a/docs/readme/README.de.md +++ b/docs/readme/README.de.md @@ -154,30 +154,88 @@ cargo clippy cargo build ``` -## Server-Bereitstellung +### Server-Bereitstellung -Codeg kann als eigenständiger Webserver ohne Tauri-Abhängigkeiten oder GUI betrieben werden. +Codeg kann als eigenständiger Webserver ohne Desktop-Umgebung betrieben werden. -### Option 1: Direktes Binary +#### Option 1: Ein-Zeilen-Installation (Linux / macOS) ```bash -pnpm server:build -./target/release/codeg-server +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash ``` +Eine bestimmte Version oder in ein benutzerdefiniertes Verzeichnis installieren: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +Dann ausführen: + +```bash +codeg-server +``` + +#### Option 2: Ein-Zeilen-Installation (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +Oder eine bestimmte Version installieren: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### Option 3: Von GitHub Releases herunterladen + +Vorkompilierte Binärdateien (mit gebündelten Web-Assets) sind auf der [Releases](https://github.com/xintaofei/codeg/releases)-Seite verfügbar: + +| Plattform | Datei | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# Beispiel: Herunterladen, Entpacken und Ausführen +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### Option 4: Docker + +```bash +docker compose up -d + +# Oder direkt ausführen +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### Option 5: Aus Quellcode kompilieren + +```bash +pnpm install && pnpm build # Frontend kompilieren +cd src-tauri +cargo build --release --bin codeg-server --no-default-features +CODEG_STATIC_DIR=../out ./target/release/codeg-server +``` + +#### Konfiguration + +Umgebungsvariablen: + | Variable | Standardwert | Beschreibung | | --- | --- | --- | -| CODEG_PORT | 3080 | HTTP-Port | -| CODEG_HOST | 0.0.0.0 | Bind-Adresse | -| CODEG_TOKEN | (zufällig) | Authentifizierungstoken | -| CODEG_DATA_DIR | ~/.local/share/codeg | SQLite-Datenbankverzeichnis | -| CODEG_STATIC_DIR | ./web oder ./out | Next.js-Statikexport-Verzeichnis | - -### Option 2: Docker - -```bash -docker compose up -``` +| `CODEG_PORT` | `3080` | HTTP-Port | +| `CODEG_HOST` | `0.0.0.0` | Bind-Adresse | +| `CODEG_TOKEN` | *(zufällig)* | Authentifizierungstoken (wird beim Start auf stderr ausgegeben) | +| `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite-Datenbankverzeichnis | +| `CODEG_STATIC_DIR` | `./web` oder `./out` | Next.js-Statikexport-Verzeichnis | ## Architektur diff --git a/docs/readme/README.es.md b/docs/readme/README.es.md index ac1bf74..faecb2f 100644 --- a/docs/readme/README.es.md +++ b/docs/readme/README.es.md @@ -154,30 +154,88 @@ cargo clippy cargo build ``` -## Despliegue del servidor +### Despliegue del servidor -Codeg puede ejecutarse como un servidor web independiente sin dependencias de Tauri ni GUI. +Codeg puede ejecutarse como un servidor web independiente sin entorno de escritorio. -### Opción 1: Binario directo +#### Opción 1: Instalación en una línea (Linux / macOS) ```bash -pnpm server:build -./target/release/codeg-server +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash ``` +Instalar una versión específica o en un directorio personalizado: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +Luego ejecutar: + +```bash +codeg-server +``` + +#### Opción 2: Instalación en una línea (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +O instalar una versión específica: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### Opción 3: Descargar desde GitHub Releases + +Los binarios precompilados (con recursos web incluidos) están disponibles en la página de [Releases](https://github.com/xintaofei/codeg/releases): + +| Plataforma | Archivo | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# Ejemplo: descargar, extraer y ejecutar +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### Opción 4: Docker + +```bash +docker compose up -d + +# O ejecutar directamente +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### Opción 5: Compilar desde el código fuente + +```bash +pnpm install && pnpm build # compilar frontend +cd src-tauri +cargo build --release --bin codeg-server --no-default-features +CODEG_STATIC_DIR=../out ./target/release/codeg-server +``` + +#### Configuración + +Variables de entorno: + | Variable | Valor por defecto | Descripción | | --- | --- | --- | -| CODEG_PORT | 3080 | Puerto HTTP | -| CODEG_HOST | 0.0.0.0 | Dirección de enlace | -| CODEG_TOKEN | (aleatorio) | Token de autenticación | -| CODEG_DATA_DIR | ~/.local/share/codeg | Directorio de base de datos SQLite | -| CODEG_STATIC_DIR | ./web o ./out | Directorio de exportación estática de Next.js | - -### Opción 2: Docker - -```bash -docker compose up -``` +| `CODEG_PORT` | `3080` | Puerto HTTP | +| `CODEG_HOST` | `0.0.0.0` | Dirección de enlace | +| `CODEG_TOKEN` | *(aleatorio)* | Token de autenticación (se imprime en stderr al iniciar) | +| `CODEG_DATA_DIR` | `~/.local/share/codeg` | Directorio de base de datos SQLite | +| `CODEG_STATIC_DIR` | `./web` o `./out` | Directorio de exportación estática de Next.js | ## Arquitectura diff --git a/docs/readme/README.fr.md b/docs/readme/README.fr.md index d64a8d3..7cc13ef 100644 --- a/docs/readme/README.fr.md +++ b/docs/readme/README.fr.md @@ -152,30 +152,88 @@ cargo clippy cargo build ``` -## Déploiement du serveur +### Déploiement du serveur -Codeg peut fonctionner comme un serveur web autonome sans dépendances Tauri ni interface graphique. +Codeg peut fonctionner comme un serveur web autonome sans environnement de bureau. -### Option 1 : Binaire direct +#### Option 1 : Installation en une ligne (Linux / macOS) ```bash -pnpm server:build -./target/release/codeg-server +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash ``` +Installer une version spécifique ou dans un répertoire personnalisé : + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +Puis exécuter : + +```bash +codeg-server +``` + +#### Option 2 : Installation en une ligne (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +Ou installer une version spécifique : + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### Option 3 : Télécharger depuis GitHub Releases + +Les binaires pré-compilés (avec les ressources web incluses) sont disponibles sur la page [Releases](https://github.com/xintaofei/codeg/releases) : + +| Plateforme | Fichier | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# Exemple : télécharger, extraire et exécuter +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### Option 4 : Docker + +```bash +docker compose up -d + +# Ou exécuter directement +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### Option 5 : Compiler depuis les sources + +```bash +pnpm install && pnpm build # compiler le frontend +cd src-tauri +cargo build --release --bin codeg-server --no-default-features +CODEG_STATIC_DIR=../out ./target/release/codeg-server +``` + +#### Configuration + +Variables d'environnement : + | Variable | Valeur par défaut | Description | | --- | --- | --- | -| CODEG_PORT | 3080 | Port HTTP | -| CODEG_HOST | 0.0.0.0 | Adresse de liaison | -| CODEG_TOKEN | (aléatoire) | Jeton d'authentification | -| CODEG_DATA_DIR | ~/.local/share/codeg | Répertoire de base de données SQLite | -| CODEG_STATIC_DIR | ./web ou ./out | Répertoire d'export statique Next.js | - -### Option 2 : Docker - -```bash -docker compose up -``` +| `CODEG_PORT` | `3080` | Port HTTP | +| `CODEG_HOST` | `0.0.0.0` | Adresse de liaison | +| `CODEG_TOKEN` | *(aléatoire)* | Jeton d'authentification (affiché sur stderr au démarrage) | +| `CODEG_DATA_DIR` | `~/.local/share/codeg` | Répertoire de base de données SQLite | +| `CODEG_STATIC_DIR` | `./web` ou `./out` | Répertoire d'export statique Next.js | ## Architecture diff --git a/docs/readme/README.ja.md b/docs/readme/README.ja.md index 4a06ddd..cf29d10 100644 --- a/docs/readme/README.ja.md +++ b/docs/readme/README.ja.md @@ -156,17 +156,75 @@ cargo build Codeg はデスクトップ環境なしでスタンドアロン Web サーバーとして実行できます。 -#### オプション 1: バイナリ直接実行 +#### オプション 1: ワンラインインストール(Linux / macOS) ```bash -# サーバーバイナリのビルド +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +特定のバージョンまたはカスタムディレクトリにインストール: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +実行: + +```bash +codeg-server +``` + +#### オプション 2: ワンラインインストール(Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +または特定のバージョンをインストール: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### オプション 3: GitHub Releases からダウンロード + +ビルド済みバイナリ(Web アセットをバンドル済み)は [Releases](https://github.com/xintaofei/codeg/releases) ページからダウンロードできます: + +| プラットフォーム | ファイル | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# 例: ダウンロード、解凍、実行 +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### オプション 4: Docker + +```bash +docker compose up -d + +# または直接実行 +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### オプション 5: ソースからビルド + +```bash +pnpm install && pnpm build # フロントエンドをビルド cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# 実行 -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### 設定 + 環境変数: | 変数 | デフォルト | 説明 | @@ -175,18 +233,7 @@ CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server | `CODEG_HOST` | `0.0.0.0` | バインドアドレス | | `CODEG_TOKEN` | *(ランダム)* | 認証トークン(起動時に stderr に出力) | | `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite データベースディレクトリ | -| `CODEG_STATIC_DIR` | `./web` or `./out` | Next.js 静的エクスポートディレクトリ | - -#### オプション 2: Docker - -```bash -# ビルドして実行 -docker compose up -d - -# または手動でビルド -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` +| `CODEG_STATIC_DIR` | `./web` または `./out` | Next.js 静的エクスポートディレクトリ | ## アーキテクチャ diff --git a/docs/readme/README.ko.md b/docs/readme/README.ko.md index 67418b5..4b1c5ac 100644 --- a/docs/readme/README.ko.md +++ b/docs/readme/README.ko.md @@ -156,17 +156,75 @@ cargo build Codeg는 데스크톱 환경 없이 독립형 웹 서버로 실행할 수 있습니다. -#### 옵션 1: 바이너리 직접 실행 +#### 옵션 1: 원라인 설치 (Linux / macOS) ```bash -# 서버 바이너리 빌드 +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +특정 버전 또는 사용자 지정 디렉토리에 설치: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +실행: + +```bash +codeg-server +``` + +#### 옵션 2: 원라인 설치 (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +또는 특정 버전 설치: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### 옵션 3: GitHub Releases에서 다운로드 + +사전 빌드된 바이너리(웹 에셋 포함)는 [Releases](https://github.com/xintaofei/codeg/releases) 페이지에서 다운로드할 수 있습니다: + +| 플랫폼 | 파일 | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# 예시: 다운로드, 압축 해제, 실행 +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### 옵션 4: Docker + +```bash +docker compose up -d + +# 또는 직접 실행 +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### 옵션 5: 소스에서 빌드 + +```bash +pnpm install && pnpm build # 프론트엔드 빌드 cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# 실행 -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### 구성 + 환경 변수: | 변수 | 기본값 | 설명 | @@ -175,18 +233,7 @@ CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server | `CODEG_HOST` | `0.0.0.0` | 바인드 주소 | | `CODEG_TOKEN` | *(랜덤)* | 인증 토큰 (시작 시 stderr에 출력) | | `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite 데이터베이스 디렉토리 | -| `CODEG_STATIC_DIR` | `./web` or `./out` | Next.js 정적 내보내기 디렉토리 | - -#### 옵션 2: Docker - -```bash -# 빌드 및 실행 -docker compose up -d - -# 또는 수동으로 빌드 -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` +| `CODEG_STATIC_DIR` | `./web` 또는 `./out` | Next.js 정적 내보내기 디렉토리 | ## 아키텍처 diff --git a/docs/readme/README.pt.md b/docs/readme/README.pt.md index a887918..2831ba1 100644 --- a/docs/readme/README.pt.md +++ b/docs/readme/README.pt.md @@ -156,17 +156,75 @@ cargo build O Codeg pode ser executado como um servidor web standalone sem ambiente desktop. -#### Opção 1: Binário direto +#### Opção 1: Instalação em uma linha (Linux / macOS) ```bash -# Build do binário do servidor +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +Instalar uma versão específica ou em um diretório personalizado: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +Em seguida, executar: + +```bash +codeg-server +``` + +#### Opção 2: Instalação em uma linha (Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +Ou instalar uma versão específica: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### Opção 3: Baixar do GitHub Releases + +Binários pré-compilados (com recursos web incluídos) estão disponíveis na página de [Releases](https://github.com/xintaofei/codeg/releases): + +| Plataforma | Arquivo | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# Exemplo: baixar, extrair e executar +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### Opção 4: Docker + +```bash +docker compose up -d + +# Ou executar diretamente +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### Opção 5: Compilar a partir do código-fonte + +```bash +pnpm install && pnpm build # compilar frontend cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# Executar -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### Configuração + Variáveis de ambiente: | Variável | Padrão | Descrição | @@ -177,17 +235,6 @@ Variáveis de ambiente: | `CODEG_DATA_DIR` | `~/.local/share/codeg` | Diretório do banco de dados SQLite | | `CODEG_STATIC_DIR` | `./web` ou `./out` | Diretório de exportação estática do Next.js | -#### Opção 2: Docker - -```bash -# Build e execução -docker compose up -d - -# Ou build manual -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` - ## Arquitetura ```text diff --git a/docs/readme/README.zh-CN.md b/docs/readme/README.zh-CN.md index f5d5779..089630d 100644 --- a/docs/readme/README.zh-CN.md +++ b/docs/readme/README.zh-CN.md @@ -156,17 +156,75 @@ cargo build Codeg 可以作为独立 Web 服务器运行,无需桌面环境。 -#### 方式一:直接运行二进制 +#### 方式一:一键安装(Linux / macOS) ```bash -# 构建服务器二进制 +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +安装指定版本或到自定义目录: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +然后运行: + +```bash +codeg-server +``` + +#### 方式二:一键安装(Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +或安装指定版本: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### 方式三:从 GitHub Releases 下载 + +预构建二进制文件(已打包 Web 前端资源)可在 [Releases](https://github.com/xintaofei/codeg/releases) 页面下载: + +| 平台 | 文件 | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# 示例:下载、解压、运行 +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### 方式四:Docker + +```bash +docker compose up -d + +# 或直接运行 +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### 方式五:从源码构建 + +```bash +pnpm install && pnpm build # 构建前端 cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# 运行 -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### 配置 + 环境变量: | 变量 | 默认值 | 说明 | @@ -177,17 +235,6 @@ CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server | `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite 数据库目录 | | `CODEG_STATIC_DIR` | `./web` 或 `./out` | Next.js 静态导出目录 | -#### 方式二:Docker - -```bash -# 构建并运行 -docker compose up -d - -# 或手动构建 -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` - ## 架构 ```text diff --git a/docs/readme/README.zh-TW.md b/docs/readme/README.zh-TW.md index 565bb9f..af79382 100644 --- a/docs/readme/README.zh-TW.md +++ b/docs/readme/README.zh-TW.md @@ -156,17 +156,75 @@ cargo build Codeg 可以作為獨立 Web 伺服器執行,無需桌面環境。 -#### 方式一:直接執行二進位檔 +#### 方式一:一鍵安裝(Linux / macOS) ```bash -# 建置伺服器二進位檔 +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +``` + +安裝指定版本或到自訂目錄: + +```bash +curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 --dir ~/.local/bin +``` + +然後執行: + +```bash +codeg-server +``` + +#### 方式二:一鍵安裝(Windows PowerShell) + +```powershell +irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +``` + +或安裝指定版本: + +```powershell +.\install.ps1 -Version v0.5.0 +``` + +#### 方式三:從 GitHub Releases 下載 + +預建置二進位檔(已打包 Web 前端資源)可在 [Releases](https://github.com/xintaofei/codeg/releases) 頁面下載: + +| 平台 | 檔案 | +| --- | --- | +| Linux x64 | `codeg-server-linux-x64.tar.gz` | +| Linux arm64 | `codeg-server-linux-arm64.tar.gz` | +| macOS x64 | `codeg-server-darwin-x64.tar.gz` | +| macOS arm64 | `codeg-server-darwin-arm64.tar.gz` | +| Windows x64 | `codeg-server-windows-x64.zip` | + +```bash +# 範例:下載、解壓縮、執行 +tar xzf codeg-server-linux-x64.tar.gz +cd codeg-server-linux-x64 +CODEG_STATIC_DIR=./web ./codeg-server +``` + +#### 方式四:Docker + +```bash +docker compose up -d + +# 或直接執行 +docker run -p 3080:3080 -v codeg-data:/data ghcr.io/xintaofei/codeg:latest +``` + +#### 方式五:從原始碼建置 + +```bash +pnpm install && pnpm build # 建置前端 cd src-tauri cargo build --release --bin codeg-server --no-default-features - -# 執行 -CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server +CODEG_STATIC_DIR=../out ./target/release/codeg-server ``` +#### 設定 + 環境變數: | 變數 | 預設值 | 說明 | @@ -177,17 +235,6 @@ CODEG_PORT=3080 CODEG_STATIC_DIR=../out ./target/release/codeg-server | `CODEG_DATA_DIR` | `~/.local/share/codeg` | SQLite 資料庫目錄 | | `CODEG_STATIC_DIR` | `./web` 或 `./out` | Next.js 靜態匯出目錄 | -#### 方式二:Docker - -```bash -# 建置並執行 -docker compose up -d - -# 或手動建置 -docker build -t codeg . -docker run -p 3080:3080 -v codeg-data:/data codeg -``` - ## 架構 ```text diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..58e54ad --- /dev/null +++ b/install.ps1 @@ -0,0 +1,90 @@ +# +# Codeg Server installer for Windows +# Usage: +# irm https://raw.githubusercontent.com/xintaofei/codeg/main/install.ps1 | iex +# .\install.ps1 -Version v0.5.0 +# + +param( + [string]$Version = "", + [string]$InstallDir = "$env:LOCALAPPDATA\codeg" +) + +$ErrorActionPreference = "Stop" +$Repo = "xintaofei/codeg" +$Artifact = "codeg-server-windows-x64" + +# ── Resolve version ── + +if (-not $Version) { + Write-Host "Fetching latest release..." + $release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest" + $Version = $release.tag_name + if (-not $Version) { + Write-Error "Could not determine latest version" + exit 1 + } +} + +Write-Host "Installing codeg-server $Version (windows/x64)..." + +# ── Download and extract ── + +$Url = "https://github.com/$Repo/releases/download/$Version/$Artifact.zip" +$TmpDir = Join-Path $env:TEMP "codeg-install-$(Get-Random)" +New-Item -ItemType Directory -Force -Path $TmpDir | Out-Null +$ZipPath = Join-Path $TmpDir "$Artifact.zip" + +Write-Host "Downloading $Url..." +try { + Invoke-WebRequest -Uri $Url -OutFile $ZipPath -UseBasicParsing +} catch { + Write-Error "Download failed. Check that version $Version exists and has a $Artifact asset." + exit 1 +} + +Write-Host "Extracting..." +Expand-Archive -Path $ZipPath -DestinationPath $TmpDir -Force + +# ── Install ── + +New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null + +$BinarySrc = Join-Path $TmpDir $Artifact "codeg-server.exe" +if (-not (Test-Path $BinarySrc)) { + Write-Error "Binary not found in archive" + exit 1 +} +Copy-Item $BinarySrc -Destination (Join-Path $InstallDir "codeg-server.exe") -Force + +# Install web assets +$WebSrc = Join-Path $TmpDir $Artifact "web" +$WebDir = Join-Path $InstallDir "web" +if (Test-Path $WebSrc) { + Write-Host "Installing web assets to $WebDir..." + if (Test-Path $WebDir) { Remove-Item $WebDir -Recurse -Force } + Copy-Item $WebSrc -Destination $WebDir -Recurse +} + +# ── Add to PATH ── + +$UserPath = [Environment]::GetEnvironmentVariable("Path", "User") +if ($UserPath -notlike "*$InstallDir*") { + [Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User") + Write-Host "Added $InstallDir to user PATH (restart terminal to take effect)" +} + +# ── Cleanup ── + +Remove-Item $TmpDir -Recurse -Force -ErrorAction SilentlyContinue + +# ── Done ── + +Write-Host "" +Write-Host "codeg-server installed to $InstallDir\codeg-server.exe" +Write-Host "" +Write-Host "Quick start:" +Write-Host " `$env:CODEG_STATIC_DIR=`"$WebDir`"; codeg-server" +Write-Host "" +Write-Host "Or with custom settings:" +Write-Host " `$env:CODEG_PORT=`"3080`"; `$env:CODEG_TOKEN=`"your-secret`"; `$env:CODEG_STATIC_DIR=`"$WebDir`"; codeg-server" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..6dd6f45 --- /dev/null +++ b/install.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# +# Codeg Server installer +# Usage: +# curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash +# curl -fsSL https://raw.githubusercontent.com/xintaofei/codeg/main/install.sh | bash -s -- --version v0.5.0 +# + +set -euo pipefail + +REPO="xintaofei/codeg" +INSTALL_DIR="${CODEG_INSTALL_DIR:-/usr/local/bin}" +VERSION="" + +# ── Parse arguments ── + +while [[ $# -gt 0 ]]; do + case "$1" in + --version) VERSION="$2"; shift 2 ;; + --dir) INSTALL_DIR="$2"; shift 2 ;; + --help) + echo "Usage: install.sh [--version VERSION] [--dir INSTALL_DIR]" + echo "" + echo "Options:" + echo " --version Version to install (e.g. v0.5.0). Default: latest" + echo " --dir Installation directory. Default: /usr/local/bin" + exit 0 + ;; + *) echo "Unknown option: $1"; exit 1 ;; + esac +done + +# ── Detect platform ── + +OS="$(uname -s)" +ARCH="$(uname -m)" + +case "$OS" in + Linux) PLATFORM="linux" ;; + Darwin) PLATFORM="darwin" ;; + *) echo "Error: unsupported OS: $OS"; exit 1 ;; +esac + +case "$ARCH" in + x86_64|amd64) ARCH_SUFFIX="x64" ;; + aarch64|arm64) ARCH_SUFFIX="arm64" ;; + *) echo "Error: unsupported architecture: $ARCH"; exit 1 ;; +esac + +ARTIFACT="codeg-server-${PLATFORM}-${ARCH_SUFFIX}" + +# ── Resolve version ── + +if [ -z "$VERSION" ]; then + echo "Fetching latest release..." + VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ + | grep '"tag_name"' | head -1 | cut -d'"' -f4) + if [ -z "$VERSION" ]; then + echo "Error: could not determine latest version" + exit 1 + fi +fi + +echo "Installing codeg-server ${VERSION} (${PLATFORM}/${ARCH_SUFFIX})..." + +# ── Download and extract ── + +DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARTIFACT}.tar.gz" +TMP_DIR=$(mktemp -d) +trap 'rm -rf "$TMP_DIR"' EXIT + +echo "Downloading ${DOWNLOAD_URL}..." +if ! curl -fSL --progress-bar -o "${TMP_DIR}/${ARTIFACT}.tar.gz" "$DOWNLOAD_URL"; then + echo "Error: download failed. Check that version ${VERSION} exists and has a ${ARTIFACT} asset." + exit 1 +fi + +echo "Extracting..." +tar xzf "${TMP_DIR}/${ARTIFACT}.tar.gz" -C "$TMP_DIR" + +# ── Install binary ── + +BINARY_SRC="${TMP_DIR}/${ARTIFACT}/codeg-server" +if [ ! -f "$BINARY_SRC" ]; then + echo "Error: binary not found in archive" + exit 1 +fi + +mkdir -p "$INSTALL_DIR" +if [ -w "$INSTALL_DIR" ]; then + cp "$BINARY_SRC" "${INSTALL_DIR}/codeg-server" + chmod +x "${INSTALL_DIR}/codeg-server" +else + echo "Need sudo to install to ${INSTALL_DIR}" + sudo cp "$BINARY_SRC" "${INSTALL_DIR}/codeg-server" + sudo chmod +x "${INSTALL_DIR}/codeg-server" +fi + +# ── Install web assets ── + +WEB_SRC="${TMP_DIR}/${ARTIFACT}/web" +WEB_DIR="${CODEG_WEB_DIR:-/usr/local/share/codeg/web}" + +if [ -d "$WEB_SRC" ]; then + echo "Installing web assets to ${WEB_DIR}..." + if [ -w "$(dirname "$WEB_DIR")" ] 2>/dev/null; then + mkdir -p "$WEB_DIR" + cp -r "$WEB_SRC"/* "$WEB_DIR"/ + else + sudo mkdir -p "$WEB_DIR" + sudo cp -r "$WEB_SRC"/* "$WEB_DIR"/ + fi +fi + +# ── Done ── + +echo "" +echo "codeg-server installed to ${INSTALL_DIR}/codeg-server" +echo "" +echo "Quick start:" +echo " CODEG_STATIC_DIR=${WEB_DIR} codeg-server" +echo "" +echo "Or with custom settings:" +echo " CODEG_PORT=3080 CODEG_TOKEN=your-secret CODEG_STATIC_DIR=${WEB_DIR} codeg-server" +echo "" +echo "The auth token is printed to stderr on startup if not set via CODEG_TOKEN."