From da2212735624990010e26a199162f64fca0ed3da Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 8 Apr 2026 12:43:00 +0000 Subject: [PATCH] add standalone install script and arm64 .deb support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a curl|bash installer (packaging/install.sh) that detects platform/arch and downloads the right prebuilt binary from GitHub Releases — no Node/npm/Bun required. Also adds arm64 .deb to the release pipeline and includes amesh-agent in the deb package. https://claude.ai/code/session_01LQtmjMpHoyPb3bH2ZFZ3p2 --- .github/workflows/release-packages.yml | 23 ++-- packaging/install.sh | 141 +++++++++++++++++++++++++ packaging/nfpm.yaml | 6 +- 3 files changed, 163 insertions(+), 7 deletions(-) create mode 100755 packaging/install.sh diff --git a/.github/workflows/release-packages.yml b/.github/workflows/release-packages.yml index c828724..f9ae624 100644 --- a/.github/workflows/release-packages.yml +++ b/.github/workflows/release-packages.yml @@ -59,6 +59,15 @@ jobs: release-deb: needs: build-binary + strategy: + matrix: + include: + - platform: linux-x64 + nfpm_arch: amd64 + deb_arch: amd64 + - platform: linux-arm64 + nfpm_arch: arm64 + deb_arch: arm64 runs-on: ubuntu-latest permissions: contents: write @@ -69,16 +78,16 @@ jobs: id: version run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" - - name: Download linux-x64 binary + - name: Download ${{ matrix.platform }} binary uses: robinraju/release-downloader@v1 with: tag: ${{ github.ref_name }} - fileName: amesh-${{ steps.version.outputs.VERSION }}-linux-x64.tar.gz + fileName: amesh-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz - name: Extract binary run: | mkdir -p packaging/dist - tar -xzf amesh-${{ steps.version.outputs.VERSION }}-linux-x64.tar.gz -C packaging/dist/ + tar -xzf amesh-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz -C packaging/dist/ - name: Install nfpm run: | @@ -89,14 +98,16 @@ jobs: - name: Build .deb working-directory: packaging run: | - VERSION=${{ steps.version.outputs.VERSION }} nfpm pkg \ + VERSION=${{ steps.version.outputs.VERSION }} \ + NFPM_ARCH=${{ matrix.nfpm_arch }} \ + nfpm pkg \ --packager deb \ - --target ../amesh_${{ steps.version.outputs.VERSION }}_amd64.deb + --target ../amesh_${{ steps.version.outputs.VERSION }}_${{ matrix.deb_arch }}.deb - name: Upload .deb to GitHub Release uses: softprops/action-gh-release@v2 with: - files: amesh_${{ steps.version.outputs.VERSION }}_amd64.deb + files: amesh_${{ steps.version.outputs.VERSION }}_${{ matrix.deb_arch }}.deb update-homebrew: needs: build-binary diff --git a/packaging/install.sh b/packaging/install.sh new file mode 100755 index 0000000..2da2573 --- /dev/null +++ b/packaging/install.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash +# install.sh — standalone installer for amesh (no Node/npm/Bun required) +# +# Usage: +# curl -fsSL https://raw.githubusercontent.com/ameshdev/amesh/main/packaging/install.sh | bash +# +# Options (via env vars): +# VERSION=0.5.1 Install a specific version (default: latest) +# INSTALL_DIR=/path Install to a custom directory (default: /usr/local/bin) +# +# Supported platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64 + +set -euo pipefail + +REPO="ameshdev/amesh" +INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" + +# --- Helpers ---------------------------------------------------------------- + +info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } +warn() { printf '\033[1;33mwarning:\033[0m %s\n' "$*" >&2; } +error() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; } + +need_cmd() { + command -v "$1" > /dev/null 2>&1 || error "Required command not found: $1" +} + +# --- Detect platform -------------------------------------------------------- + +detect_platform() { + local os arch + + os="$(uname -s)" + case "$os" in + Linux) os="linux" ;; + Darwin) os="darwin" ;; + *) error "Unsupported OS: $os" ;; + esac + + arch="$(uname -m)" + case "$arch" in + x86_64|amd64) arch="x64" ;; + aarch64|arm64) arch="arm64" ;; + *) error "Unsupported architecture: $arch" ;; + esac + + echo "${os}-${arch}" +} + +# --- Resolve version -------------------------------------------------------- + +resolve_version() { + if [ -n "${VERSION:-}" ]; then + echo "$VERSION" + return + fi + + info "Fetching latest release version..." + + local tag + # Try GitHub API first, fall back to redirect-based detection. + if command -v curl > /dev/null 2>&1; then + tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//')" + elif command -v wget > /dev/null 2>&1; then + tag="$(wget -qO- "https://api.github.com/repos/${REPO}/releases/latest" \ + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//')" + else + error "Either curl or wget is required" + fi + + [ -n "$tag" ] || error "Could not determine latest release version" + + # Strip leading 'v' if present + echo "${tag#v}" +} + +# --- Download --------------------------------------------------------------- + +download() { + local url="$1" dest="$2" + + if command -v curl > /dev/null 2>&1; then + curl -fSL --progress-bar -o "$dest" "$url" + elif command -v wget > /dev/null 2>&1; then + wget -q --show-progress -O "$dest" "$url" + else + error "Either curl or wget is required" + fi +} + +# --- Main ------------------------------------------------------------------- + +main() { + local platform version tarball url tmpdir + + platform="$(detect_platform)" + version="$(resolve_version)" + tarball="amesh-${version}-${platform}.tar.gz" + url="https://github.com/${REPO}/releases/download/v${version}/${tarball}" + + info "Installing amesh v${version} for ${platform}" + info "Download: ${url}" + + tmpdir="$(mktemp -d)" + trap 'rm -rf "$tmpdir"' EXIT + + download "$url" "${tmpdir}/${tarball}" + + info "Extracting..." + tar -xzf "${tmpdir}/${tarball}" -C "$tmpdir" + + # Install all binaries found in the tarball. + local installed=0 + for bin in amesh amesh-agent amesh-se-helper; do + if [ -f "${tmpdir}/${bin}" ]; then + # Use sudo if we can't write to INSTALL_DIR directly. + if [ -w "$INSTALL_DIR" ]; then + install -m 755 "${tmpdir}/${bin}" "${INSTALL_DIR}/${bin}" + else + info "Elevated permissions required to install to ${INSTALL_DIR}" + sudo install -m 755 "${tmpdir}/${bin}" "${INSTALL_DIR}/${bin}" + fi + installed=$((installed + 1)) + fi + done + + [ "$installed" -gt 0 ] || error "No binaries found in tarball" + + info "Installed to ${INSTALL_DIR}" + + # Verify + if command -v amesh-agent > /dev/null 2>&1; then + info "amesh-agent is ready! Run 'amesh-agent --help' to get started." + elif [ -x "${INSTALL_DIR}/amesh-agent" ]; then + warn "${INSTALL_DIR} is not in your PATH. Add it with:" + warn " export PATH=\"${INSTALL_DIR}:\$PATH\"" + fi +} + +main "$@" diff --git a/packaging/nfpm.yaml b/packaging/nfpm.yaml index 49b7e1c..db4cbe9 100644 --- a/packaging/nfpm.yaml +++ b/packaging/nfpm.yaml @@ -1,5 +1,5 @@ name: amesh -arch: amd64 +arch: "${NFPM_ARCH}" platform: linux version: "${VERSION}" maintainer: "amesh " @@ -11,3 +11,7 @@ contents: dst: /usr/bin/amesh file_info: mode: 0755 + - src: ./dist/amesh-agent + dst: /usr/bin/amesh-agent + file_info: + mode: 0755