Repository navigation
Expand file tree
/
Copy pathrelease-plugins.sh
More file actions
executable file
·128 lines (108 loc) · 4.81 KB
/
Copy pathrelease-plugins.sh
File metadata and controls
executable file
·128 lines (108 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Bump every engine consumer listed in plugins.json. Each consumer's own
# ./release.sh knows which files carry its version; this orchestrator walks the
# registry, asks each one to bump only, and writes the new versions back to
# plugins.json. Nothing is built: `just release` builds what ships, so a build
# here would be thrown away.
#
# Commits nothing: `just plugins-release` commits VGraph's half on a release
# branch, and `just publish-plugins` commits each plugin's bump together with
# the engine it ships.
#
# Usage:
# ./release-plugins.sh # patch bump every plugin
# ./release-plugins.sh --minor # minor bump every plugin
# ./release-plugins.sh --major # major bump every plugin
# ./release-plugins.sh <plugin-path> # patch bump just that plugin
# # (use the 'path' field from plugins.json,
# # e.g. 'obsidian-vithanco')
# ./release-plugins.sh <plugin-path> --minor
set -euo pipefail
MONOREPO=$(cd "$(dirname "$0")" && pwd)
REGISTRY="$MONOREPO/plugins.json"
if [[ ! -f "$REGISTRY" ]]; then
echo "Error: $REGISTRY not found."
exit 1
fi
# ---- 1. Parse args --------------------------------------------------------
#
# Accept up to two positional args: a plugin path filter and/or a bump flag,
# in either order. Default is "all plugins, patch bump".
FILTER=""
BUMP_FLAG=""
for arg in "$@"; do
case "$arg" in
--patch|--minor|--major) BUMP_FLAG="$arg" ;;
# An explicit version, which each release.sh already accepts. Without
# this it fell through to FILTER and silently patch-bumped instead —
# and `just` is the only interface some of us want to use, so the
# driver has to take everything the scripts it drives take.
[0-9]*.[0-9]*.[0-9]*) BUMP_FLAG="$arg" ;;
*) FILTER="$arg" ;;
esac
done
# ---- 2. Read registry --------------------------------------------------
# Each line printed by node is "<path>\t<version>". Read via a portable
# while-loop (macOS bash 3.2 has no `mapfile`).
REGISTRY_LINES=$(node -e "
const reg = require('$REGISTRY');
for (const p of reg.plugins) {
console.log(p.path + '\t' + p.version);
}
")
# ---- 3. Iterate and bump --------------------------------------------------
SUMMARY=""
RAN_ANY=0
while IFS=$'\t' read -r PLUGIN_PATH OLD_VERSION; do
[[ -z "$PLUGIN_PATH" ]] && continue
PLUGIN_DIR="$MONOREPO/$PLUGIN_PATH"
if [[ -n "$FILTER" && "$FILTER" != "$PLUGIN_PATH" ]]; then
continue
fi
if [[ ! -d "$PLUGIN_DIR" ]]; then
echo "WARN: $PLUGIN_PATH listed in plugins.json but directory missing — skipping."
continue
fi
if [[ ! -x "$PLUGIN_DIR/release.sh" ]]; then
echo "WARN: $PLUGIN_DIR/release.sh missing or not executable — skipping."
continue
fi
echo ""
echo "━━━ $PLUGIN_PATH (current $OLD_VERSION) ━━━"
( cd "$PLUGIN_DIR" && ./release.sh --bump-only ${BUMP_FLAG:-} )
# Read what the plugin landed on. Both plugins keep their version in their
# manifest (Obsidian) or package.json — manifest.json if present, else
# package.json, both have a top-level "version" string.
if [[ -f "$PLUGIN_DIR/manifest.json" ]]; then
NEW_VERSION=$(node -p "require('$PLUGIN_DIR/manifest.json').version")
else
NEW_VERSION=$(node -p "require('$PLUGIN_DIR/package.json').version")
fi
SUMMARY="${SUMMARY}${PLUGIN_PATH}: ${OLD_VERSION} → ${NEW_VERSION}"$'\n'
RAN_ANY=1
# ---- 4. Write the new version back to plugins.json --------------------
node -e "
const fs = require('fs');
const reg = JSON.parse(fs.readFileSync('$REGISTRY', 'utf8'));
const p = reg.plugins.find(p => p.path === '$PLUGIN_PATH');
if (p) p.version = '$NEW_VERSION';
fs.writeFileSync('$REGISTRY', JSON.stringify(reg, null, 2) + '\n');
"
done <<< "$REGISTRY_LINES"
if [[ "$RAN_ANY" -eq 0 ]]; then
if [[ -n "$FILTER" ]]; then
echo "No plugin matched '$FILTER'. Known paths:"
node -e "require('$REGISTRY').plugins.forEach(p => console.log(' ' + p.path))"
else
echo "No plugins in $REGISTRY."
fi
exit 1
fi
# ---- 5. Summary -----------------------------------------------------------
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✓ Plugin bumps complete"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
printf '%s' "$SUMMARY" | while IFS= read -r s; do echo " $s"; done
echo ""
echo "plugins.json updated. Nothing built or committed."