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
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,22 @@

## Install

Install from a source checkout:
Install the latest release binary:

```bash
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | sh
```

The installer supports Linux x86_64, Linux arm64, macOS x86_64, and macOS arm64
release artifacts. It installs to `~/.local/bin` by default. Override the
install directory or version with environment variables:

```bash
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | CONFLUENCE_CLI_INSTALL_DIR=/usr/local/bin sh
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | CONFLUENCE_CLI_VERSION=0.1.0 sh
```

Install from a source checkout when you need a local build:

```bash
cargo install --path .
Expand Down
16 changes: 15 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,21 @@

## 安装

从源码检出目录安装:
安装最新 release 二进制文件:

```bash
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | sh
```

安装脚本支持 Linux x86_64、Linux arm64、macOS x86_64 和 macOS arm64
release 产物。默认安装到 `~/.local/bin`。可以通过环境变量覆盖安装目录或版本:

```bash
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | CONFLUENCE_CLI_INSTALL_DIR=/usr/local/bin sh
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | CONFLUENCE_CLI_VERSION=0.1.0 sh
```

需要本地构建时,可以从源码检出目录安装:

```bash
cargo install --path .
Expand Down
112 changes: 112 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/sh
set -eu

BIN_NAME="confluence-cli"
REPO="${CONFLUENCE_CLI_REPO:-laipz8200/confluence-cli}"
GITHUB_BASE_URL="${CONFLUENCE_CLI_GITHUB_BASE_URL:-https://github.com}"
GITHUB_API_URL="${CONFLUENCE_CLI_GITHUB_API_URL:-https://api.github.com}"
REQUESTED_VERSION="${CONFLUENCE_CLI_VERSION:-latest}"

GITHUB_BASE_URL="${GITHUB_BASE_URL%/}"
GITHUB_API_URL="${GITHUB_API_URL%/}"

fail() {
printf 'confluence-cli install: %s\n' "$*" >&2
exit 1
}

need_command() {
command -v "$1" >/dev/null 2>&1 || fail "Missing required command: $1"
}

detect_target() {
os=$(uname -s)
arch=$(uname -m)

case "$os:$arch" in
Linux:x86_64 | Linux:amd64)
printf 'x86_64-unknown-linux-gnu\n'
;;
Linux:aarch64 | Linux:arm64)
printf 'aarch64-unknown-linux-gnu\n'
;;
Darwin:x86_64 | Darwin:amd64)
printf 'x86_64-apple-darwin\n'
;;
Darwin:arm64 | Darwin:aarch64)
printf 'aarch64-apple-darwin\n'
;;
*)
fail "Unsupported platform: $os/$arch. Release binaries are available for Linux x86_64, Linux arm64, macOS x86_64, and macOS arm64."
;;
esac
}

resolve_tag() {
if [ "$REQUESTED_VERSION" = "latest" ]; then
latest_json=$(curl -fsSL "$GITHUB_API_URL/repos/$REPO/releases/latest") \
|| fail "Failed to resolve the latest GitHub release."
tag=$(printf '%s\n' "$latest_json" \
| sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \
| head -n 1)
[ -n "$tag" ] || fail "Could not find a tag_name in the latest GitHub release response."
printf '%s\n' "$tag"
return
fi

case "$REQUESTED_VERSION" in
v*) printf '%s\n' "$REQUESTED_VERSION" ;;
*) printf 'v%s\n' "$REQUESTED_VERSION" ;;
esac
}

default_install_dir() {
if [ -n "${CONFLUENCE_CLI_INSTALL_DIR:-}" ]; then
printf '%s\n' "$CONFLUENCE_CLI_INSTALL_DIR"
return
fi

[ -n "${HOME:-}" ] || fail "HOME is not set. Set CONFLUENCE_CLI_INSTALL_DIR to choose an install directory."
printf '%s/.local/bin\n' "$HOME"
}

need_command curl
need_command head
need_command install
need_command mktemp
need_command sed
need_command tar
need_command uname

target="${CONFLUENCE_CLI_TARGET:-$(detect_target)}"
tag=$(resolve_tag)
version="${tag#v}"
asset="confluence-cli-$version-$target.tar.gz"
package="confluence-cli-$version-$target"
url="$GITHUB_BASE_URL/$REPO/releases/download/$tag/$asset"
install_dir=$(default_install_dir)

tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/confluence-cli.XXXXXX") \
|| fail "Failed to create a temporary directory."
cleanup() {
rm -rf "$tmpdir"
}
trap cleanup EXIT INT TERM

archive="$tmpdir/$asset"
printf 'Downloading %s\n' "$url"
curl -fsSL -o "$archive" "$url" || fail "Failed to download $asset."

tar -xzf "$archive" -C "$tmpdir" || fail "Failed to extract $asset."
binary="$tmpdir/$package/$BIN_NAME"
[ -f "$binary" ] || fail "Release archive did not contain $package/$BIN_NAME."

mkdir -p "$install_dir" || fail "Failed to create install directory: $install_dir"
install -m 0755 "$binary" "$install_dir/$BIN_NAME" \
|| fail "Failed to install $BIN_NAME to $install_dir."

printf 'Installed %s to %s\n' "$BIN_NAME" "$install_dir/$BIN_NAME"
case ":$PATH:" in
*":$install_dir:"*) ;;
*) printf 'Note: %s is not on PATH.\n' "$install_dir" ;;
esac
8 changes: 7 additions & 1 deletion skills/confluence-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ confluence-cli --version

`confluence-cli --version` prints normal CLI version text, not JSON.

If the command is missing, tell the user to install it from the `confluence-cli` repository root or another source checkout:
If the command is missing, tell the user to install the latest release binary:

```bash
curl -fsSL https://raw.githubusercontent.com/laipz8200/confluence-cli/main/install.sh | sh
```

If they need a local source build, tell them to run this from the `confluence-cli` repository root or another source checkout:

```bash
cargo install --path .
Expand Down
Loading
Loading