From 02c3c35d876afc4321d336f0209290d6d3ad6346 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 17:46:42 -0500 Subject: [PATCH 1/6] feat: curl|sh installer with sha256 verification Signed-off-by: Diego Resendez --- install.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ test_install.sh | 42 +++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100755 install.sh create mode 100755 test_install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..eeab11a --- /dev/null +++ b/install.sh @@ -0,0 +1,81 @@ +#!/bin/sh +# matcha installer — downloads a prebuilt binary from Gitea Releases. +# curl -fsSL /install.sh | sh +# Env: MATCHA_VERSION (tag, default latest), MATCHA_INSTALL_DIR (default ~/.local/bin), +# MATCHA_REPO_BASE (default the Gitea repo URL). +set -eu + +REPO_BASE="${MATCHA_REPO_BASE:-https://git.svc.zoit.services/Green-Tea/matcha}" +INSTALL_DIR="${MATCHA_INSTALL_DIR:-$HOME/.local/bin}" + +err() { echo "matcha-install: $*" >&2; exit 1; } + +if command -v curl >/dev/null 2>&1; then + fetch_out() { curl -fsSL "$1" -o "$2"; } + fetch() { curl -fsSL "$1"; } +elif command -v wget >/dev/null 2>&1; then + fetch_out() { wget -qO "$2" "$1"; } + fetch() { wget -qO- "$1"; } +else + err "need curl or wget" +fi + +if command -v sha256sum >/dev/null 2>&1; then + sha256() { sha256sum "$1" | awk '{print $1}'; } +elif command -v shasum >/dev/null 2>&1; then + sha256() { shasum -a 256 "$1" | awk '{print $1}'; } +else + err "need sha256sum or shasum" +fi + +os=$(uname -s); arch=$(uname -m) +case "$os" in + Darwin) + case "$arch" in + arm64|aarch64) triple="aarch64-apple-darwin" ;; + x86_64) triple="x86_64-apple-darwin" ;; + *) err "unsupported macOS arch: $arch" ;; + esac ;; + Linux) + case "$arch" in + x86_64|amd64) triple="x86_64-unknown-linux-musl" ;; + arm64|aarch64) err "linux arm64 has no prebuilt binary yet — use: cargo install --git $REPO_BASE" ;; + *) err "unsupported Linux arch: $arch" ;; + esac ;; + *) err "unsupported OS: $os — try: cargo install --git $REPO_BASE" ;; +esac + +version="${MATCHA_VERSION:-latest}" +if [ "$version" = "latest" ]; then + tag=$(fetch "$REPO_BASE/api/v1/repos/Green-Tea/matcha/releases/latest" \ + | grep -o '"tag_name":"[^"]*"' | head -1 | cut -d'"' -f4) + [ -n "$tag" ] || err "could not resolve latest release tag" +else + tag="$version" +fi + +asset="matcha-${triple}.tar.gz" +url="$REPO_BASE/releases/download/${tag}/${asset}" + +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +echo "matcha-install: downloading $asset ($tag)" +fetch_out "$url" "$tmp/$asset" || err "download failed: $url" +fetch_out "$url.sha256" "$tmp/$asset.sha256" || err "checksum download failed: $url.sha256" + +want=$(awk '{print $1}' < "$tmp/$asset.sha256") +got=$(sha256 "$tmp/$asset") +[ -n "$want" ] || err "empty checksum file" +[ "$want" = "$got" ] || err "checksum mismatch (want $want, got $got)" + +tar -xzf "$tmp/$asset" -C "$tmp" +[ -f "$tmp/matcha" ] || err "archive did not contain 'matcha'" +mkdir -p "$INSTALL_DIR" +chmod +x "$tmp/matcha" +mv "$tmp/matcha" "$INSTALL_DIR/matcha" + +echo "matcha-install: installed to $INSTALL_DIR/matcha ($tag)" +case ":${PATH}:" in + *":$INSTALL_DIR:"*) ;; + *) echo "matcha-install: add to PATH -> export PATH=\"$INSTALL_DIR:\$PATH\"" ;; +esac +"$INSTALL_DIR/matcha" --version 2>/dev/null || true diff --git a/test_install.sh b/test_install.sh new file mode 100755 index 0000000..f86d6d0 --- /dev/null +++ b/test_install.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Tests install.sh against a local file:// fixture (no network). +set -eu +here=$(cd "$(dirname "$0")" && pwd) +fail() { echo "FAIL: $*" >&2; exit 1; } + +# derive this machine's expected triple the same way install.sh does +os=$(uname -s); arch=$(uname -m) +case "$os" in + Darwin) case "$arch" in arm64|aarch64) triple=aarch64-apple-darwin;; x86_64) triple=x86_64-apple-darwin;; esac;; + Linux) case "$arch" in x86_64|amd64) triple=x86_64-unknown-linux-musl;; esac;; +esac +[ -n "${triple:-}" ] || { echo "SKIP: unsupported test host"; exit 0; } + +work=$(mktemp -d); trap 'rm -rf "$work"' EXIT +tag=v0.0.0 +assetdir="$work/fixture/releases/download/$tag" +mkdir -p "$assetdir" + +# build a fake release asset: a tarball containing a 'matcha' executable +printf '#!/bin/sh\necho "matcha 0.0.0-test"\n' > "$work/matcha" +chmod +x "$work/matcha" +tar -czf "$assetdir/matcha-$triple.tar.gz" -C "$work" matcha +( cd "$assetdir" && { command -v sha256sum >/dev/null 2>&1 && sha256sum "matcha-$triple.tar.gz" || shasum -a 256 "matcha-$triple.tar.gz"; } > "matcha-$triple.tar.gz.sha256" ) + +# --- case 1: happy path installs the binary --- +bin="$work/bin" +MATCHA_REPO_BASE="file://$work/fixture" MATCHA_VERSION="$tag" MATCHA_INSTALL_DIR="$bin" \ + sh "$here/install.sh" >/dev/null 2>&1 || fail "install.sh exited non-zero on happy path" +[ -x "$bin/matcha" ] || fail "matcha not installed to $bin" +"$bin/matcha" --version >/dev/null 2>&1 || fail "installed matcha not runnable" + +# --- case 2: checksum mismatch aborts and does NOT install --- +echo "deadbeef matcha-$triple.tar.gz" > "$assetdir/matcha-$triple.tar.gz.sha256" +bin2="$work/bin2" +if MATCHA_REPO_BASE="file://$work/fixture" MATCHA_VERSION="$tag" MATCHA_INSTALL_DIR="$bin2" \ + sh "$here/install.sh" >/dev/null 2>&1; then + fail "install.sh should have failed on checksum mismatch" +fi +[ -e "$bin2/matcha" ] && fail "matcha must NOT be installed on checksum mismatch" + +echo "PASS: test_install.sh" -- 2.54.1 From 8a282fa9c8520206a9ffa1bc956ed3b073806d1e Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 17:51:30 -0500 Subject: [PATCH 2/6] test: shellcheck-clean fixture checksum generation (SC2015) Signed-off-by: Diego Resendez --- test_install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test_install.sh b/test_install.sh index f86d6d0..cc246e6 100755 --- a/test_install.sh +++ b/test_install.sh @@ -21,7 +21,11 @@ mkdir -p "$assetdir" printf '#!/bin/sh\necho "matcha 0.0.0-test"\n' > "$work/matcha" chmod +x "$work/matcha" tar -czf "$assetdir/matcha-$triple.tar.gz" -C "$work" matcha -( cd "$assetdir" && { command -v sha256sum >/dev/null 2>&1 && sha256sum "matcha-$triple.tar.gz" || shasum -a 256 "matcha-$triple.tar.gz"; } > "matcha-$triple.tar.gz.sha256" ) +if command -v sha256sum >/dev/null 2>&1; then + ( cd "$assetdir" && sha256sum "matcha-$triple.tar.gz" > "matcha-$triple.tar.gz.sha256" ) +else + ( cd "$assetdir" && shasum -a 256 "matcha-$triple.tar.gz" > "matcha-$triple.tar.gz.sha256" ) +fi # --- case 1: happy path installs the binary --- bin="$work/bin" -- 2.54.1 From 48276890e82ca7cdef5a519448d6945686aa15ec Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 17:52:23 -0500 Subject: [PATCH 3/6] ci: release workflow builds binaries and publishes to Gitea Releases Signed-off-by: Diego Resendez --- .gitea/workflows/release.yml | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..23858bb --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release +on: + push: + tags: ['v*'] + +permissions: + contents: write + +jobs: + build: + strategy: + matrix: + include: + - target: aarch64-apple-darwin + os: macos-14 + - target: x86_64-apple-darwin + os: macos-14 + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable + echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + + - name: Add target + musl tooling + run: | + rustup target add ${{ matrix.target }} + if [ "${{ matrix.target }}" = "x86_64-unknown-linux-musl" ]; then + sudo apt-get update && sudo apt-get install -y musl-tools + fi + + - name: Build + run: cargo build --release --locked --target ${{ matrix.target }} + + - name: Package + run: | + TAR="matcha-${{ matrix.target }}.tar.gz" + tar -czf "$TAR" -C "target/${{ matrix.target }}/release" matcha + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$TAR" > "$TAR.sha256" + else + shasum -a 256 "$TAR" > "$TAR.sha256" + fi + + - name: Upload to release + uses: softprops/action-gh-release@v2 + with: + files: | + matcha-${{ matrix.target }}.tar.gz + matcha-${{ matrix.target }}.tar.gz.sha256 -- 2.54.1 From 7beadde4bef81af223fb51dd10f087ad26489902 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 17:56:40 -0500 Subject: [PATCH 4/6] ci: fail-fast=false so a flaky leg can't publish a partial release Signed-off-by: Diego Resendez --- .gitea/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 23858bb..9dd8f0a 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -9,6 +9,7 @@ permissions: jobs: build: strategy: + fail-fast: false matrix: include: - target: aarch64-apple-darwin -- 2.54.1 From b6304789855750c3fecb6ae8479c334a45e7a667 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 17:57:06 -0500 Subject: [PATCH 5/6] docs: install via curl|sh, cargo install --git as from-source Signed-off-by: Diego Resendez --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73f5dfc..b1312c0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,17 @@ The [green-tea](https://git.svc.zoit.services/Green-Tea/core) CLI — scaffold, ## Install ```bash -cargo install matcha # or: brew install matcha (once published) +curl -fsSL https://git.svc.zoit.services/Green-Tea/matcha/raw/branch/main/install.sh | sh +``` + +Installs a prebuilt binary to `~/.local/bin` — no Rust required. Override the +target dir with `MATCHA_INSTALL_DIR=/usr/local/bin`, or pin a version with +`MATCHA_VERSION=v26.7.0`. + +**From source** (requires Rust — compiles and installs): + +```bash +cargo install --git https://git.svc.zoit.services/Green-Tea/matcha ``` ## Usage -- 2.54.1 From 995c3cd45ef3dd281082597c129ca6d7b563c00e Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 12 Jul 2026 18:00:29 -0500 Subject: [PATCH 6/6] fix(install): tolerate whitespace in latest-tag JSON; doc env vars on pipe Signed-off-by: Diego Resendez --- README.md | 9 ++++++--- install.sh | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1312c0..d671fb8 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,12 @@ The [green-tea](https://git.svc.zoit.services/Green-Tea/core) CLI — scaffold, curl -fsSL https://git.svc.zoit.services/Green-Tea/matcha/raw/branch/main/install.sh | sh ``` -Installs a prebuilt binary to `~/.local/bin` — no Rust required. Override the -target dir with `MATCHA_INSTALL_DIR=/usr/local/bin`, or pin a version with -`MATCHA_VERSION=v26.7.0`. +Installs a prebuilt binary to `~/.local/bin` — no Rust required. Env vars go on +the `sh` side of the pipe: + +```bash +curl -fsSL …/install.sh | MATCHA_VERSION=v26.7.0 MATCHA_INSTALL_DIR=/usr/local/bin sh +``` **From source** (requires Rust — compiles and installs): diff --git a/install.sh b/install.sh index eeab11a..230b5d9 100755 --- a/install.sh +++ b/install.sh @@ -48,7 +48,7 @@ esac version="${MATCHA_VERSION:-latest}" if [ "$version" = "latest" ]; then tag=$(fetch "$REPO_BASE/api/v1/repos/Green-Tea/matcha/releases/latest" \ - | grep -o '"tag_name":"[^"]*"' | head -1 | cut -d'"' -f4) + | grep -o '"tag_name":[[:space:]]*"[^"]*"' | head -1 | cut -d'"' -f4) [ -n "$tag" ] || err "could not resolve latest release tag" else tag="$version" -- 2.54.1