fix release process
Release / release (push) Successful in 8s

This commit is contained in:
2026-09-10 13:57:21 +02:00
parent fa3d0da80b
commit 3fae7e084e
4 changed files with 20 additions and 16 deletions
+13 -10
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
for command in bun curl jq sha256sum; do
for command in bun curl jq sha256sum tar; do
command -v "$command" >/dev/null || { printf 'Required command not found: %s\n' "$command" >&2; exit 1; }
done
config="${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
mkdir -p "$config"
config=$(cd "$config" && pwd -P)
mkdir -p "$config/stanp-opencode" "$config/plugins"
install=$(mktemp -d "$config/stanp-opencode/install.XXXXXXXX")
mkdir -p "$config/plugins"
install=$(mktemp -d "$config/install.stanp-opencode.XXXXXXXX")
cleanup() {
if [[ -n "$install" ]]; then rm -rf "$install"; fi
}
@@ -33,8 +33,7 @@ if [[ ! "$actual" =~ ^[a-fA-F0-9]{64}$ || "$actual" != "$checksum" ]]; then
exit 1
fi
printf '{"private":true,"type":"module"}\n' > "$install/package.json"
(cd "$install" && bun add --production --ignore-scripts --no-cache ./stanp-opencode.tgz)
tar -xzf "$install/stanp-opencode.tgz" -C "$install"
bun -e '
if (!await Bun.file(process.argv[1]).exists()) {
throw new Error("Latest release lacks the OpenCode V2 directory entrypoint. Publish a V2-compatible release first.");
@@ -43,10 +42,14 @@ bun -e '
if (!plugin || plugin.id !== "stanp-opencode" || typeof plugin.setup !== "function") {
throw new Error("Latest release is not a native OpenCode V2 plugin. Publish a V2-compatible release first.");
}
' "$install/node_modules/stanp-opencode/index.js"
' "$install/package/dist/index.js"
tag=$(jq -r '.tag_name' "$install/release.json")
ln -s "../stanp-opencode/$(basename "$install")/node_modules/stanp-opencode" "$install/plugin"
mv -Tf "$install/plugin" "$config/plugins/stanp-opencode"
install=""
printf 'Installed stanp-opencode %s into %s/plugins/stanp-opencode\nRestart opencode2 to load it.\n' "$tag" "$config"
if ! mv -f "$install/package/dist/index.js" "$config/plugins/stanp-opencode.js"; then
printf 'Could not activate plugin; installation unchanged\n' >&2
exit 1
fi
if [[ -L "$config/plugins/stanp-opencode" ]]; then
rm -f "$config/plugins/stanp-opencode"
fi
printf 'Installed stanp-opencode %s into %s/plugins/stanp-opencode.js\nRestart opencode2 to load it.\n' "$tag" "$config"