From b4fbe8ec23dcb5bbddd7b033b4cc4c24ea786d24 Mon Sep 17 00:00:00 2001 From: StatIndet <2141964736@qq.com> Date: Mon, 24 Aug 2026 19:48:18 +0800 Subject: [PATCH 1/3] feat: implement zero-dependency release installer Adds scripts/install.sh to automatically detect platform, fetch the latest Daybook release from GitHub API, verify SHA-256 checksums, and install the prebuilt binary to ~/.local/bin without requiring Go or Node.js. --- scripts/install.sh | 143 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100755 scripts/install.sh diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..32e30c5 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +set -euo pipefail + +# GitHub repository +REPO="StatIndet/daybook" +DOWNLOAD_URL_BASE="https://github.com/${REPO}/releases" + +# Default install directory +DAYBOOK_INSTALL_DIR="${DAYBOOK_INSTALL_DIR:-${HOME}/.local/bin}" + +# Helpers +abort() { + echo "ERROR: $*" >&2 + exit 1 +} + +# 1. Detect OS & Architecture +OS="$(uname -s)" +ARCH="$(uname -m)" + +case "$OS" in + Linux) + OS_NAME="linux" + ;; + Darwin) + OS_NAME="darwin" + ;; + *) + abort "Unsupported platform: $OS/$ARCH" + ;; +esac + +case "$ARCH" in + x86_64 | amd64) + ARCH_NAME="amd64" + ;; + aarch64 | arm64) + ARCH_NAME="arm64" + ;; + *) + abort "Unsupported platform: $OS/$ARCH" + ;; +esac + +PLATFORM="${OS_NAME}_${ARCH_NAME}" +echo "=> Detected platform: $PLATFORM" + +# 2. Check dependencies +if command -v curl >/dev/null 2>&1; then + DOWNLOAD_CMD="curl -fsSL" +elif command -v wget >/dev/null 2>&1; then + DOWNLOAD_CMD="wget -qO-" +else + abort "Neither curl nor wget is available. Please install one of them to download Daybook." +fi + +if command -v sha256sum >/dev/null 2>&1; then + SHASUM_CMD="sha256sum" +elif command -v shasum >/dev/null 2>&1; then + SHASUM_CMD="shasum -a 256" +else + abort "Neither sha256sum nor shasum is available. Please install one of them for checksum verification." +fi + +if ! command -v tar >/dev/null 2>&1; then + abort "tar is not available." +fi + +# 3. Get latest release tag +echo "=> Fetching latest release info..." +API_URL="https://api.github.com/repos/${REPO}/releases/latest" +# Extract tag_name using standard text tools +LATEST_TAG=$($DOWNLOAD_CMD "$API_URL" | grep '"tag_name":' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/') + +if [ -z "$LATEST_TAG" ]; then + abort "Failed to determine the latest release tag from GitHub API." +fi + +echo "=> Latest release is $LATEST_TAG" + +# 4. Construct file names +ASSET_NAME="daybook_${LATEST_TAG}_${PLATFORM}.tar.gz" +ASSET_URL="${DOWNLOAD_URL_BASE}/download/${LATEST_TAG}/${ASSET_NAME}" +CHECKSUMS_URL="${DOWNLOAD_URL_BASE}/download/${LATEST_TAG}/checksums.txt" + +# 5. Create temp dir and download +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT INT TERM + +echo "=> Downloading $ASSET_NAME..." +$DOWNLOAD_CMD "$ASSET_URL" > "$TMP_DIR/$ASSET_NAME" || abort "Failed to download $ASSET_URL" + +echo "=> Downloading checksums.txt..." +$DOWNLOAD_CMD "$CHECKSUMS_URL" > "$TMP_DIR/checksums.txt" || abort "Failed to download checksums.txt" + +# 6. Verify checksum +echo "=> Verifying checksum..." +cd "$TMP_DIR" + +if ! grep -q "$ASSET_NAME" checksums.txt; then + abort "$ASSET_NAME not found in checksums.txt" +fi + +EXPECTED_HASH=$(grep "$ASSET_NAME" checksums.txt | awk '{print $1}') +ACTUAL_HASH=$($SHASUM_CMD "$ASSET_NAME" | awk '{print $1}') + +if [ "$EXPECTED_HASH" != "$ACTUAL_HASH" ]; then + abort "Checksum verification failed! Expected: $EXPECTED_HASH, Actual: $ACTUAL_HASH" +fi +echo "=> Checksum verified successfully." + +# 7. Extract +echo "=> Extracting archive..." +tar -xzf "$ASSET_NAME" daybook || abort "Failed to extract tar.gz" + +if [ ! -f "daybook" ]; then + abort "Extracted archive did not contain 'daybook' binary." +fi + +chmod +x daybook + +# 8. Install +echo "=> Installing daybook to $DAYBOOK_INSTALL_DIR..." +mkdir -p "$DAYBOOK_INSTALL_DIR" || abort "Failed to create directory: $DAYBOOK_INSTALL_DIR" +cp daybook "$DAYBOOK_INSTALL_DIR/daybook" || abort "Failed to copy daybook to $DAYBOOK_INSTALL_DIR. Check permissions." + +# 9. Verify installation +echo "=> Verifying installation..." +"$DAYBOOK_INSTALL_DIR/daybook" --version || abort "Failed to execute daybook after installation." + +echo "" +echo "Daybook $LATEST_TAG installed successfully." +echo "Installed to: $DAYBOOK_INSTALL_DIR/daybook" + +# 10. PATH Check +if [[ ":$PATH:" != *":$DAYBOOK_INSTALL_DIR:"* ]]; then + echo "" + echo "Daybook was installed successfully, but $DAYBOOK_INSTALL_DIR is not in your PATH." + echo "Add it to your shell PATH before using \`daybook\`:" + echo "" + echo " export PATH=\"\$PATH:$DAYBOOK_INSTALL_DIR\"" + echo "" +fi From 2e561299ce282d0334507f5c5438c4f5865727c0 Mon Sep 17 00:00:00 2001 From: StatIndet <2141964736@qq.com> Date: Mon, 24 Aug 2026 19:48:23 +0800 Subject: [PATCH 2/3] ci: publish installer script to GitHub releases Includes scripts/install.sh in the GitHub Release payload so users can download and execute it directly via the latest release endpoint. --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf98e77..602eb6a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,4 +69,5 @@ jobs: files: | daybook_*.tar.gz checksums.txt + scripts/install.sh generate_release_notes: true From 23423ae11068082c969307a28b208e103ebc8137 Mon Sep 17 00:00:00 2001 From: StatIndet <2141964736@qq.com> Date: Mon, 24 Aug 2026 19:48:28 +0800 Subject: [PATCH 3/3] docs: update installation instructions with curl downloader Documents the new curl installation path pointing to the GitHub releases latest download endpoint, clarifying the separation from the build-from-source method. --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 96c05b8..fec4c94 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,22 @@ my-vault/ ## Installation ### Prebuilt Binaries (Recommended) -You can download prebuilt standalone binaries for your platform from [GitHub Releases](https://github.com/StatIndet/daybook/releases). -Supported platforms: Linux (amd64/arm64) and macOS (Intel/Apple Silicon). +The easiest way to install Daybook is using our release installer. This script will automatically detect your OS and architecture, download the latest prebuilt CLI, verify its checksum, and install it to `~/.local/bin`. -Extract the archive and place the `daybook` executable in your system's `PATH`. +```bash +curl -fsSL https://github.com/StatIndet/daybook/releases/latest/download/install.sh | bash +``` +Alternatively, you can manually download the binaries from [GitHub Releases](https://github.com/StatIndet/daybook/releases). ### Build from Source -To build the CLI from source, ensure you have **Go** and **Node.js** (>=24) installed. +Building from source is recommended for development. Ensure you have **Go**, **Node.js** (>=24), and **npm** installed. ```bash git clone https://github.com/StatIndet/daybook.git cd daybook ./scripts/install-cli.sh ``` -This script installs npm dependencies, builds frontend assets, and installs the `daybook` executable to your Go bin path. +This script installs npm dependencies, builds frontend assets, and installs the `daybook` executable to your Go bin path (`$GOBIN` or `$(go env GOPATH)/bin`). ## CLI Commands