diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e65c4d7..9d907a65 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,7 +53,10 @@ jobs: wget \ file \ patchelf \ - libssl-dev + libssl-dev \ + rpm \ + flatpak \ + flatpak-builder # GTK/GLib stack for gdk-3.0, glib-2.0, gio-2.0 sudo apt-get install -y --no-install-recommends \ libgtk-3-dev \ @@ -153,7 +156,7 @@ jobs: - name: Build Tauri App (Linux) if: runner.os == 'Linux' - run: pnpm tauri build + run: pnpm tauri build -- --bundles appimage,deb,rpm - name: Prepare macOS Assets if: runner.os == 'macOS' @@ -271,6 +274,28 @@ jobs: else echo "No .deb found (optional)" fi + # 额外上传 .rpm(用于 Fedora/RHEL/openSUSE 等,不参与 Updater) + RPM=$(find src-tauri/target/release/bundle -name "*.rpm" | head -1 || true) + if [ -n "$RPM" ]; then + NEW_RPM="CC-Switch-${VERSION}-Linux.rpm" + cp "$RPM" "release-assets/$NEW_RPM" + echo "RPM package copied: $NEW_RPM" + else + echo "No .rpm found (optional)" + fi + # 额外上传 .flatpak(跨发行版;不参与 Updater) + if [ -n "$DEB" ]; then + echo "Building Flatpak bundle from .deb..." + cp "$DEB" flatpak/cc-switch.deb + flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + flatpak install -y --user flathub org.gnome.Platform//46 org.gnome.Sdk//46 + flatpak-builder --force-clean --user --disable-cache --repo flatpak-repo flatpak-build flatpak/com.ccswitch.desktop.yml + NEW_FLATPAK="CC-Switch-${VERSION}-Linux.flatpak" + flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo flatpak-repo "release-assets/$NEW_FLATPAK" com.ccswitch.desktop + echo "Flatpak bundle created: $NEW_FLATPAK" + else + echo "Skip Flatpak build: no .deb found" + fi - name: List prepared assets shell: bash @@ -299,7 +324,7 @@ jobs: - **macOS**: `CC-Switch-${{ github.ref_name }}-macOS.zip`(解压即用)或 `CC-Switch-${{ github.ref_name }}-macOS.tar.gz`(Homebrew) - **Windows**: `CC-Switch-${{ github.ref_name }}-Windows.msi`(安装版)或 `CC-Switch-${{ github.ref_name }}-Windows-Portable.zip`(绿色版) - - **Linux**: `CC-Switch-${{ github.ref_name }}-Linux.AppImage`(AppImage)或 `CC-Switch-${{ github.ref_name }}-Linux.deb`(Debian/Ubuntu) + - **Linux**: `CC-Switch-${{ github.ref_name }}-Linux.AppImage`(AppImage)或 `CC-Switch-${{ github.ref_name }}-Linux.deb`(Debian/Ubuntu)或 `CC-Switch-${{ github.ref_name }}-Linux.rpm`(Fedora/RHEL/openSUSE)或 `CC-Switch-${{ github.ref_name }}-Linux.flatpak`(Flatpak) --- 提示:macOS 如遇"已损坏"提示,可在终端执行:`xattr -cr "/Applications/CC Switch.app"` diff --git a/.gitignore b/.gitignore index 6ed52a49..49a8be78 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,8 @@ GEMINI.md /.vscode vitest-report.json nul + +# Flatpak build artifacts +flatpak/cc-switch.deb +flatpak-build/ +flatpak-repo/ diff --git a/README.md b/README.md index 1684228e..0d7d6718 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,19 @@ paru -S cc-switch-bin ### Linux Users -Download the latest `CC-Switch-v{version}-Linux.deb` package or `CC-Switch-v{version}-Linux.AppImage` from the [Releases](../../releases) page. +Download the latest Linux build from the [Releases](../../releases) page: + +- `CC-Switch-v{version}-Linux.deb` (Debian/Ubuntu) +- `CC-Switch-v{version}-Linux.rpm` (Fedora/RHEL/openSUSE) +- `CC-Switch-v{version}-Linux.AppImage` (Universal) +- `CC-Switch-v{version}-Linux.flatpak` (Flatpak) + +Flatpak install & run: + +```bash +flatpak install --user ./CC-Switch-v{version}-Linux.flatpak +flatpak run com.ccswitch.desktop +``` ## Quick Start diff --git a/README_JA.md b/README_JA.md index aefc6474..e02e5515 100644 --- a/README_JA.md +++ b/README_JA.md @@ -186,7 +186,19 @@ paru -S cc-switch-bin ### Linux ユーザー -[Releases](../../releases) から最新版の `CC-Switch-v{version}-Linux.deb` または `CC-Switch-v{version}-Linux.AppImage` をダウンロード。 +[Releases](../../releases) から最新版の Linux ビルドをダウンロード: + +- `CC-Switch-v{version}-Linux.deb`(Debian/Ubuntu) +- `CC-Switch-v{version}-Linux.rpm`(Fedora/RHEL/openSUSE) +- `CC-Switch-v{version}-Linux.AppImage`(汎用) +- `CC-Switch-v{version}-Linux.flatpak`(Flatpak) + +Flatpak のインストールと起動: + +```bash +flatpak install --user ./CC-Switch-v{version}-Linux.flatpak +flatpak run com.ccswitch.desktop +``` ## クイックスタート diff --git a/README_ZH.md b/README_ZH.md index c5c37fc9..98f683e5 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -186,7 +186,19 @@ paru -S cc-switch-bin ### Linux 用户 -从 [Releases](../../releases) 页面下载最新版本的 `CC-Switch-v{版本号}-Linux.deb` 包或者 `CC-Switch-v{版本号}-Linux.AppImage` 安装包。 +从 [Releases](../../releases) 页面下载最新版本的 Linux 安装包: + +- `CC-Switch-v{版本号}-Linux.deb`(Debian/Ubuntu) +- `CC-Switch-v{版本号}-Linux.rpm`(Fedora/RHEL/openSUSE) +- `CC-Switch-v{版本号}-Linux.AppImage`(通用) +- `CC-Switch-v{版本号}-Linux.flatpak`(Flatpak) + +Flatpak 安装与运行: + +```bash +flatpak install --user ./CC-Switch-v{版本号}-Linux.flatpak +flatpak run com.ccswitch.desktop +``` ## 快速开始 diff --git a/flatpak/README.md b/flatpak/README.md new file mode 100644 index 00000000..b8c4efab --- /dev/null +++ b/flatpak/README.md @@ -0,0 +1,63 @@ +# Flatpak Build Guide + +This directory contains the Flatpak manifest (`com.ccswitch.desktop`) for CC Switch, used to convert the generated `.deb` artifact into an installable `.flatpak` package via CI or local builds. + +## Dependencies + +- `flatpak` +- `flatpak-builder` +- Flathub remote (for installing `org.gnome.Platform//46` runtime) + +For Ubuntu/Debian: + +```bash +sudo apt install flatpak flatpak-builder +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +flatpak install -y --user flathub org.gnome.Platform//46 org.gnome.Sdk//46 +``` + +## Local Build (Generate .flatpak from .deb) + +1) Build the deb on Linux first: + +```bash +pnpm tauri build -- --bundles deb +``` + +2) Copy the generated deb to this directory: + +```bash +cp "$(find src-tauri/target/release/bundle -name '*.deb' | head -n 1)" flatpak/cc-switch.deb +``` + +3) Build the local Flatpak repository and export the `.flatpak`: + +```bash +flatpak-builder --force-clean --user --disable-cache --repo flatpak-repo flatpak-build flatpak/com.ccswitch.desktop.yml +flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo flatpak-repo CC-Switch-Linux.flatpak com.ccswitch.desktop +``` + +4) Install and run: + +```bash +flatpak install --user ./CC-Switch-Linux.flatpak +flatpak run com.ccswitch.desktop +``` + +## Permissions Note + +The current manifest uses `--filesystem=home` by default for "download and run" convenience, allowing the app to directly read/write CLI configuration files and app data on the host (and supporting the "directory override" feature). + +If you prefer minimal permissions (e.g., for Flathub submission or security concerns), you can replace `--filesystem=home` in `flatpak/com.ccswitch.desktop.yml` with more precise grants: + +```yaml + - --filesystem=~/.cc-switch:create + - --filesystem=~/.claude:create + - --filesystem=~/.claude.json + - --filesystem=~/.codex:create + - --filesystem=~/.gemini:create +``` + +Note: Flatpak's `:create` modifier only works with directories, not files. Therefore, `~/.claude.json` cannot use `:create`. If this file doesn't exist on the user's machine, the app may not be able to create it with restricted permissions. Users should either run Claude Code once to generate it, or manually create an empty JSON file (content: `{}`). + +If you plan to publish on Flathub or want stricter permission control, adjust the `finish-args` in `flatpak/com.ccswitch.desktop.yml` accordingly. diff --git a/flatpak/com.ccswitch.desktop.desktop b/flatpak/com.ccswitch.desktop.desktop new file mode 100644 index 00000000..f659def7 --- /dev/null +++ b/flatpak/com.ccswitch.desktop.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=CC Switch +Comment=All-in-One Assistant for Claude Code, Codex & Gemini CLI +Exec=cc-switch +Icon=com.ccswitch.desktop +Terminal=false +Categories=Utility;Development; +StartupNotify=true diff --git a/flatpak/com.ccswitch.desktop.metainfo.xml b/flatpak/com.ccswitch.desktop.metainfo.xml new file mode 100644 index 00000000..bbabf2bb --- /dev/null +++ b/flatpak/com.ccswitch.desktop.metainfo.xml @@ -0,0 +1,25 @@ + + + com.ccswitch.desktop + CC Switch + All-in-One Assistant for Claude Code, Codex & Gemini CLI + CC0-1.0 + MIT + + +

CC Switch is a cross-platform desktop app for managing and switching provider configurations for Claude Code, Codex, and Gemini CLI.

+ +
+ + com.ccswitch.desktop.desktop + + cc-switch + + + https://github.com/farion1231/cc-switch + https://github.com/farion1231/cc-switch/issues +
diff --git a/flatpak/com.ccswitch.desktop.yml b/flatpak/com.ccswitch.desktop.yml new file mode 100644 index 00000000..b4e08856 --- /dev/null +++ b/flatpak/com.ccswitch.desktop.yml @@ -0,0 +1,45 @@ +id: com.ccswitch.desktop + +runtime: org.gnome.Platform +runtime-version: '46' +sdk: org.gnome.Sdk + +command: cc-switch + +finish-args: + - --share=ipc + - --share=network + - --socket=wayland + - --socket=fallback-x11 + - --device=dri + # Tray icon permissions (required by Tauri tray-icon) + - --talk-name=org.kde.StatusNotifierWatcher + - --filesystem=xdg-run/tray-icon:create + # GitHub Releases scenario: Users download and install manually. + # For "download and run" convenience (needs read/write access to ~/.cc-switch, ~/.claude, ~/.claude.json, ~/.codex, ~/.gemini, + # and supports custom directory overrides), we grant full Home access by default. + # If you plan to publish on Flathub or prefer minimal permissions, replace this with more precise directory grants (see flatpak/README.md). + - --filesystem=home + +modules: + - name: cc-switch + buildsystem: simple + sources: + # Placed in flatpak/ directory by CI or local build script + - type: file + path: cc-switch.deb + - type: file + path: com.ccswitch.desktop.desktop + - type: file + path: com.ccswitch.desktop.metainfo.xml + - type: file + path: ../src-tauri/icons/128x128.png + build-commands: + - ar -x *.deb + - tar -xf data.tar.* + - cp -a usr/* /app/ + # Use our own desktop/metainfo/icon to align with Flatpak app id + - rm -f /app/share/applications/*.desktop + - install -Dm644 com.ccswitch.desktop.desktop /app/share/applications/com.ccswitch.desktop.desktop + - install -Dm644 com.ccswitch.desktop.metainfo.xml /app/share/metainfo/com.ccswitch.desktop.metainfo.xml + - install -Dm644 128x128.png /app/share/icons/hicolor/128x128/apps/com.ccswitch.desktop.png