Replaces the fish-only plugin with one portable binary — completions for bash/zsh/fish/PowerShell via `ccswitch completions <shell>`. Same UX (save/add/use/list/current/rm/isolate/seed/search + bare-name switch-and-launch). - Fixes the auth-loss bug: the OAuth token is per-account (org lives only in ~/.claude.json), so switching between same-login/different-org profiles left the sibling holding a rotated, dead refresh token. A switch now propagates the refreshed credential to every profile sharing the account. - Adds `save --force` / `add --force` to overwrite a profile without rm first. - macOS Keychain via `security` (shim); file-based creds on Linux/Windows. - Ports-and-adapters; 100% line / 98.86% region coverage; clippy + fmt clean. - Homebrew formula (auto-installs completions) + cask + release workflow. - Old fish plugin preserved under legacy-fish/ (also at lei-wego/ccswitch-fish). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
220 lines
7.4 KiB
YAML
220 lines
7.4 KiB
YAML
name: release
|
|
|
|
# Cut a release by pushing a tag like v0.1.0.
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Existing tag to (re)build, e.g. v0.1.0"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
BIN: ccswitch
|
|
|
|
jobs:
|
|
build:
|
|
name: build ${{ matrix.target }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: macos-14
|
|
target: aarch64-apple-darwin
|
|
# x86_64 mac is cross-compiled on the Apple-Silicon runner — the
|
|
# scarce macos-13 Intel runner was leaving releases stuck in queue.
|
|
- os: macos-14
|
|
target: x86_64-apple-darwin
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
- os: ubuntu-24.04-arm
|
|
target: aarch64-unknown-linux-gnu
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Resolve tag
|
|
id: tag
|
|
shell: bash
|
|
env:
|
|
INPUT_TAG: ${{ github.event.inputs.tag }}
|
|
REF_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
tag="${INPUT_TAG:-$REF_NAME}"
|
|
if ! printf '%s' "$tag" | grep -qE '^v[0-9A-Za-z.+-]+$'; then
|
|
echo "::error::invalid tag '$tag'"; exit 1
|
|
fi
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.target }}
|
|
- name: Build
|
|
run: cargo build --release --locked --target ${{ matrix.target }}
|
|
- name: Package
|
|
id: pkg
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
tag="${{ steps.tag.outputs.tag }}"
|
|
name="${BIN}-${tag}-${{ matrix.target }}"
|
|
dist="dist/$name"
|
|
mkdir -p "$dist"
|
|
cp "target/${{ matrix.target }}/release/${BIN}" "$dist/"
|
|
cp README.md LICENSE "$dist/" 2>/dev/null || true
|
|
tar -C "$dist" -czf "dist/$name.tar.gz" . # binary at archive root
|
|
( cd dist && shasum -a 256 "$name.tar.gz" > "$name.tar.gz.sha256" )
|
|
echo "artifact=dist/$name.tar.gz" >> "$GITHUB_OUTPUT"
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.target }}
|
|
path: dist/*.tar.gz*
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: publish release + bump cask
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Resolve tag
|
|
id: tag
|
|
shell: bash
|
|
env:
|
|
INPUT_TAG: ${{ github.event.inputs.tag }}
|
|
REF_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
tag="${INPUT_TAG:-$REF_NAME}"
|
|
if ! printf '%s' "$tag" | grep -qE '^v[0-9A-Za-z.+-]+$'; then
|
|
echo "::error::invalid tag '$tag'"; exit 1
|
|
fi
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
- name: Collect artifacts
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p dist
|
|
find artifacts -type f \( -name '*.tar.gz' -o -name '*.sha256' \) -exec cp {} dist/ \;
|
|
ls -l dist
|
|
- name: Create GitHub release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.tag.outputs.tag }}
|
|
generate_release_notes: true
|
|
files: dist/*
|
|
- name: Bump Homebrew cask
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
tag="${{ steps.tag.outputs.tag }}"
|
|
version="${tag#v}"
|
|
sha() { cut -d' ' -f1 "dist/${BIN}-${tag}-$1.tar.gz.sha256"; }
|
|
arm_mac=$(sha aarch64-apple-darwin)
|
|
x86_mac=$(sha x86_64-apple-darwin)
|
|
arm_lin=$(sha aarch64-unknown-linux-gnu)
|
|
x86_lin=$(sha x86_64-unknown-linux-gnu)
|
|
mkdir -p Casks
|
|
cat > Casks/ccswitch.rb <<RUBY
|
|
# Auto-generated by .github/workflows/release.yml on each tag. Do not edit by hand.
|
|
cask "ccswitch" do
|
|
version "${version}"
|
|
|
|
on_macos do
|
|
on_arm do
|
|
sha256 "${arm_mac}"
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-aarch64-apple-darwin.tar.gz"
|
|
end
|
|
on_intel do
|
|
sha256 "${x86_mac}"
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-x86_64-apple-darwin.tar.gz"
|
|
end
|
|
end
|
|
on_linux do
|
|
on_arm do
|
|
sha256 "${arm_lin}"
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-aarch64-unknown-linux-gnu.tar.gz"
|
|
end
|
|
on_intel do
|
|
sha256 "${x86_lin}"
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-x86_64-unknown-linux-gnu.tar.gz"
|
|
end
|
|
end
|
|
|
|
livecheck do
|
|
url :url
|
|
strategy :github_latest
|
|
end
|
|
|
|
name "ccswitch"
|
|
desc "Switch between multiple Claude Code accounts"
|
|
homepage "https://github.com/mysqto/ccswitch"
|
|
|
|
binary "ccswitch"
|
|
end
|
|
RUBY
|
|
mkdir -p Formula
|
|
cat > Formula/ccswitch.rb <<RUBY
|
|
# Auto-generated by .github/workflows/release.yml on each tag. Do not edit by hand.
|
|
class Ccswitch < Formula
|
|
desc "Cross-shell switcher for multiple Claude Code accounts"
|
|
homepage "https://github.com/mysqto/ccswitch"
|
|
version "${version}"
|
|
|
|
on_macos do
|
|
on_arm do
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-aarch64-apple-darwin.tar.gz"
|
|
sha256 "${arm_mac}"
|
|
end
|
|
on_intel do
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-x86_64-apple-darwin.tar.gz"
|
|
sha256 "${x86_mac}"
|
|
end
|
|
end
|
|
on_linux do
|
|
on_arm do
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-aarch64-unknown-linux-gnu.tar.gz"
|
|
sha256 "${arm_lin}"
|
|
end
|
|
on_intel do
|
|
url "https://github.com/mysqto/ccswitch/releases/download/v#{version}/ccswitch-v#{version}-x86_64-unknown-linux-gnu.tar.gz"
|
|
sha256 "${x86_lin}"
|
|
end
|
|
end
|
|
|
|
livecheck do
|
|
url :url
|
|
strategy :github_latest
|
|
end
|
|
|
|
def install
|
|
bin.install "ccswitch"
|
|
generate_completions_from_executable(bin/"ccswitch", "completions")
|
|
end
|
|
|
|
test do
|
|
assert_match "ccswitch", shell_output("#{bin}/ccswitch --help")
|
|
end
|
|
end
|
|
RUBY
|
|
- name: Commit cask + formula
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
git config user.name "mysqto"
|
|
git config user.email "my@mysq.to"
|
|
if ! git diff --quiet -- Casks/ccswitch.rb Formula/ccswitch.rb; then
|
|
git add Casks/ccswitch.rb Formula/ccswitch.rb
|
|
git commit -m "brew: bump cask + formula to ${{ steps.tag.outputs.tag }}"
|
|
git push origin HEAD:main
|
|
else
|
|
echo "cask + formula unchanged"
|
|
fi
|