1#!/usr/bin/env bash2# bootstrap.sh — put a product binary in place, and the graphos-factory-core3# link beside it.4#5# bootstrap.sh # download the binary (the default for users)6# bootstrap.sh --build # build it from crate/ with cargo (for developing the skill)7# bootstrap.sh --check # exit 0 if a binary reporting the pinned version is installed, 127 if not8#9# Run through a skill's own scripts/bootstrap.sh, which sets10# GRAPHOS_FACTORY_CORE_BIN_NAME to its product's binary and execs this one;11# without the variable this script refuses (exit 1). The binary lands in12# $GRAPHOS_FACTORY_CORE_CACHE/bin/<name> (default13# ~/.cache/graphos-factory-core/<owner>-<repo>, see cache.sh), next to the router14
# and WireMock the e2e layer caches, with bin/graphos-factory-core a symlink
15# to it: the shared references write `graphos-factory-core <command>`, so a
16# command copied from one runs whichever product installed it. Every wrapper
17# script looks there first, then on PATH. The wrappers (resolve-bin.sh)
18# refuse, with exit 78, a binary older than the version this script
19# installs — so a cache left behind by an old bootstrap fails loudly instead
20# of rendering silently. Nothing is ever written into the
21# repository.
22#
23# Download channels (GitHub Releases of $GRAPHOS_FACTORY_CORE_RELEASE_REPO, by
24# default the `repository` of crate/Cargo.toml, or of release.env in a copy):
25# release tag <tag>, asset <name>-<tag>-<target>.tar.gz: cache.sh's
26# release tag (a product release, from release.env) or v<pin>.
27# edge the rolling pre-release rebuilt from main on every push, asset
28# <name>-edge-<target>.tar.gz; re-downloaded whenever the
29# pre-release points at a new commit.
30# GRAPHOS_FACTORY_CORE_CHANNEL=auto (default) uses that release when it
31# exists and falls back to edge; `release` or `edge`
32# force one. A GH_TOKEN / GITHUB_TOKEN is used when present (the repository
33# may be private); without one the plain download URL is tried and, when it
34# fails, the script says so and how to fix it.
35#
36# Exit codes: 0 installed · 1 usage error (GRAPHOS_FACTORY_CORE_BIN_NAME unset among them), or the binary just installed reports the wrong version · 127 could not install, or (--check) the pinned version is not installed.
66 echo "bootstrap: GRAPHOS_FACTORY_CORE_BIN_NAME is unset: run your skill's own bootstrap (skills/<skill>/scripts/bootstrap.sh), which names its binary and runs this one" >&2
67 exit 1 ;;
68 graphos-factory-core|*/*|*[!a-z0-9-]*)
69 echo "bootstrap: GRAPHOS_FACTORY_CORE_BIN_NAME=$NAME is not a product binary's name" >&2
70 exit 1 ;;
71esac
72case "$CHANNEL" in auto|release|edge) ;; *) echo "bootstrap: GRAPHOS_FACTORY_CORE_CHANNEL must be auto, release or edge" >&2; exit 1 ;; esac
75[ -n "$VERSION" ] || { echo "bootstrap: cannot determine the version (no $CRATE/Cargo.toml, no release.env beside $HERE and no GRAPHOS_FACTORY_CORE_VERSION)" >&2; exit 1; }
76
77# The release that carries the pinned binary: a product release names its
78# own tag in release.env; a checkout's binary is released as v<version>.