Skip to content
Open
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
23 changes: 17 additions & 6 deletions .github/workflows/release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
141 changes: 141 additions & 0 deletions packaging/install.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
6 changes: 5 additions & 1 deletion packaging/nfpm.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: amesh
arch: amd64
arch: "${NFPM_ARCH}"
platform: linux
version: "${VERSION}"
maintainer: "amesh <hello@authmesh.dev>"
Expand All @@ -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
Loading