From d3ece56cba18332c5147ade7f7007f020ca33fc1 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Mon, 14 Sep 2026 10:10:10 -0400 Subject: [PATCH] v0.0.5 - Add run.sh to build (only if needed) and run the latest binary --- Cargo.lock | 12 +++---- Cargo.toml | 2 +- VERSION | 2 +- run.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/version.rs | 4 +-- 5 files changed, 96 insertions(+), 10 deletions(-) create mode 100755 run.sh diff --git a/Cargo.lock b/Cargo.lock index ead8d83..2f38e04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1957,7 +1957,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" [[package]] name = "nostr-core" -version = "0.0.3" +version = "0.1.0" dependencies = [ "aes", "base64", @@ -1979,7 +1979,7 @@ dependencies = [ [[package]] name = "nostr-nips" -version = "0.0.3" +version = "0.1.0" dependencies = [ "aes", "block-modes", @@ -2001,7 +2001,7 @@ dependencies = [ [[package]] name = "nostr-relay" -version = "0.0.3" +version = "0.1.0" dependencies = [ "futures-util", "nostr-core", @@ -2019,7 +2019,7 @@ dependencies = [ [[package]] name = "nostr-services" -version = "0.0.3" +version = "0.1.0" dependencies = [ "nostr-core", "nostr-relay", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "nostr-signer" -version = "0.0.3" +version = "0.1.0" dependencies = [ "aes", "cbc", @@ -3056,7 +3056,7 @@ dependencies = [ [[package]] name = "sovereign-browser" -version = "0.0.3" +version = "0.0.4" dependencies = [ "anyhow", "base64", diff --git a/Cargo.toml b/Cargo.toml index 0015ba8..8b7e11d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ [package] name = "sovereign-browser" -version = "0.0.4" +version = "0.0.5" edition = "2021" license = "MIT" description = "A Linux x86 web browser built on WebKitGTK with Nostr identity" diff --git a/VERSION b/VERSION index 81340c7..bbdeab6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.4 +0.0.5 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..419b43a --- /dev/null +++ b/run.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -e + +# run.sh - Build (only if needed) and run the sovereign-browser binary. +# +# Usage: +# ./run.sh [args...] # build if stale, then run with args +# ./run.sh --build # force a rebuild, then run +# ./run.sh --no-build # run without building (fails if missing) +# +# The binary is rebuilt only when it is missing or when any source file +# (src/**, Cargo.toml, Cargo.lock, www/**) is newer than the binary. + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +print_status() { echo -e "${BLUE}[INFO]${NC} $1" >&2; } +print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" >&2; } +print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" >&2; } +print_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; } + +# --- Config ------------------------------------------------------------- +# Resolve the project root as the directory containing this script. +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +BIN_NAME="sovereign-browser" +BIN_PATH="target/release/${BIN_NAME}" + +# --- Args --------------------------------------------------------------- +FORCE_BUILD=false +NO_BUILD=false +RUN_ARGS=() + +for arg in "$@"; do + case "$arg" in + --build) + FORCE_BUILD=true + ;; + --no-build) + NO_BUILD=true + ;; + *) + RUN_ARGS+=("$arg") + ;; + esac +done + +# --- Determine whether a build is needed -------------------------------- +needs_build() { + # No binary yet -> must build. + [[ ! -x "$BIN_PATH" ]] && return 0 + + # Any tracked source file newer than the binary -> rebuild. + local newer + newer="$(find src www Cargo.toml Cargo.lock \ + -type f -newer "$BIN_PATH" -print -quit 2>/dev/null || true)" + [[ -n "$newer" ]] +} + +# --- Build -------------------------------------------------------------- +if [[ "$NO_BUILD" == true ]]; then + if [[ ! -x "$BIN_PATH" ]]; then + print_error "Binary not found at ${BIN_PATH} and --no-build was given." + exit 1 + fi + print_status "Skipping build (--no-build)." +elif [[ "$FORCE_BUILD" == true ]]; then + print_status "Forcing rebuild of ${BIN_NAME} (release)..." + cargo build --release + print_success "Build complete." +elif needs_build; then + print_status "Sources changed or binary missing; building ${BIN_NAME} (release)..." + cargo build --release + print_success "Build complete." +else + print_status "Binary is up to date; skipping build." +fi + +# --- Run ---------------------------------------------------------------- +print_status "Running ${BIN_PATH} ${RUN_ARGS[*]}" +exec "$BIN_PATH" "${RUN_ARGS[@]}" diff --git a/src/version.rs b/src/version.rs index ae1f4ae..5480393 100644 --- a/src/version.rs +++ b/src/version.rs @@ -1,7 +1,7 @@ //! Version information for sovereign_browser /// The current version of sovereign_browser (with leading 'v'). -pub const VERSION: &str = "v0.0.4"; +pub const VERSION: &str = "v0.0.5"; /// Major version number. pub const VERSION_MAJOR: u32 = 0; @@ -10,4 +10,4 @@ pub const VERSION_MAJOR: u32 = 0; pub const VERSION_MINOR: u32 = 0; /// Patch version number. -pub const VERSION_PATCH: u32 = 4; +pub const VERSION_PATCH: u32 = 5;