Setting the file. One moment. Cache · Graphos Factory · apollographql/skills · Skills Docs10.20
Release
(opens in a new tab)
graphos-factory-core/scripts/cache.sh
Shell·63 lines·4 KB
# `version`, else release.env's `version`,
15# else empty ($GRAPHOS_FACTORY_CORE_VERSION,
16# read by those scripts, overrides it)
17# GRAPHOS_FACTORY_CORE_PIN_FROM where the pin was read: crate/Cargo.toml,
18# release.env or empty
19# GRAPHOS_FACTORY_CORE_RELEASE_TAG $GRAPHOS_FACTORY_CORE_RELEASE_TAG, else
20# release.env's `tag` (the release of the
21# product this copy ships with, which carries
22# the binary it pins), else empty: bootstrap.sh
23# then uses v<pin>
24#
25# crate/Cargo.toml is looked for two levels above this directory, where a
26# checkout keeps it. A copy of the core that travels inside an installed
27# skill (a skill directory copied on its own, with no crate/ above it)
28# carries release.env beside scripts/ instead: `version=X.Y.Z` (the binary),
29# `repository=owner/repo` and `tag=vA.B.C` (the product release) lines,
30# written when the copy was made. It is read, never sourced.
31# GRAPHOS_FACTORY_CORE_CACHE_DIR $GRAPHOS_FACTORY_CORE_CACHE, else
32# ~/.cache/graphos-factory-core/<owner>-<repo>, so
33# two products' builds never overwrite each
34# other
35#
36# Its bin/ holds the product binary bootstrap.sh installed and
37# `graphos-factory-core`, a link to it.
38# Bash 3.2 compatible (macOS /bin/bash).
39
40_fc_here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
41# The repository root: these scripts live in graphos-factory-core/scripts/.
42_fc_root="$(cd "$_fc_here/../.." && pwd)"
43_fc_release="$_fc_here/../release.env"
44# shellcheck disable=SC2034 # the pin is read by the scripts that source this one
45_fc_repo="" _fc_tag="" GRAPHOS_FACTORY_CORE_PIN="" GRAPHOS_FACTORY_CORE_PIN_FROM=""
46# shellcheck disable=SC2034
47if [ -f "$_fc_root/crate/Cargo.toml" ]; then
48 _fc_repo="$(sed -n 's#^repository = "https://github.com/\([^"]*\)".*#\1#p' "$_fc_root/crate/Cargo.toml" | head -1)"
49 GRAPHOS_FACTORY_CORE_PIN="$(sed -n 's/^version = "\([^"]*\)".*/\1/p' "$_fc_root/crate/Cargo.toml" | head -1)"
50 [ -z "$GRAPHOS_FACTORY_CORE_PIN" ] || GRAPHOS_FACTORY_CORE_PIN_FROM=crate/Cargo.toml
51elif [ -f "$_fc_release" ]; then
52 _fc_tag="$(sed -n 's/^tag=\([0-9A-Za-z.+_-]*\)$/\1/p' "$_fc_release" | head -1)"
53 _fc_repo="$(sed -n 's#^repository=\([A-Za-z0-9._-]*/[A-Za-z0-9._-]*\)$#\1#p' "$_fc_release" | head -1)"
54 GRAPHOS_FACTORY_CORE_PIN="$(sed -n 's/^version=\([0-9A-Za-z.+-]*\)$/\1/p' "$_fc_release" | head -1)"
55 [ -z "$GRAPHOS_FACTORY_CORE_PIN" ] || GRAPHOS_FACTORY_CORE_PIN_FROM=release.env
56fi
57GRAPHOS_FACTORY_CORE_RELEASE_REPO="${GRAPHOS_FACTORY_CORE_RELEASE_REPO:-$_fc_repo}"
58# shellcheck disable=SC2034 # read by bootstrap.sh
59GRAPHOS_FACTORY_CORE_RELEASE_TAG="${GRAPHOS_FACTORY_CORE_RELEASE_TAG:-$_fc_tag}"
60_fc_slug="${GRAPHOS_FACTORY_CORE_RELEASE_REPO:-local}"
61# shellcheck disable=SC2034 # read by the scripts that source this one
62GRAPHOS_FACTORY_CORE_CACHE_DIR="${GRAPHOS_FACTORY_CORE_CACHE:-$HOME/.cache/graphos-factory-core/${_fc_slug//\//-}}"
63unset _fc_here _fc_root _fc_release _fc_repo _fc_tag _fc_slug