scorpiox-bot-plugin-webhook
←release-dist.shbash
50 lines · 2 KBHEADBlameDownload
1#!/bin/sh
2# release-dist.sh - build + publish the six dist targets for this plugin.
3#
4# The cross-target build, the dist upload and the plugingit mirror all live in
5# scorpiox-cli-botplugin (it owns the musl / aarch64 / MinGW toolchains and the
6# macOS builder). This wrapper exists so the release is repeatable and so an
7# audit failure stops it before anything is published.
8#
9# ./release-dist.sh # publish the version in plugin.json
10# VERSION=1.0.1 ./release-dist.sh # explicit version
11#
12# Run it on the build host that has musl-gcc, aarch64-linux-gnu-gcc,
13# x86_64-w64-mingw32-gcc and ssh access to the macOS builder.
14#
15# SSHPASS must be exported: without it the macOS leg answers
16# "build: macOS skipped: SSHPASS not set" and the dist upload fails, while the
17# run still prints "build ok: <slug> (4 target(s) built)". Always read the
18# target count out of latest.json afterwards - it must be 6.
19
20set -eu
21
22SLUG=webhook
23ROOT=$(cd "$(dirname "$0")" && pwd)
24VERSION="${VERSION:-$(python3 -c 'import json,sys;print(json.load(open("'"$ROOT"'/plugin.json"))["version"])')}"
25# A private address must never be written into this public repository (the
26# history scanner refuses it, and rightly so), so the builder is supplied by the
27# environment rather than defaulted here.
28MACOS_HOST="${MACOS_HOST:?set MACOS_HOST to user@mac-builder (sshd with SSHPASS)}"
29
30if ! command -v scorpiox-cli-botplugin >/dev/null 2>&1; then
31 echo "scorpiox-cli-botplugin not found on PATH" >&2
32 exit 1
33fi
34
35echo "==> audit $SLUG"
36scorpiox-cli-botplugin audit "$ROOT" --json || { echo "audit blocked the release" >&2; exit 4; }
37
38echo "==> publish $SLUG $VERSION"
39scorpiox-cli-botplugin publish "$ROOT" \
40 --slug "$SLUG" \
41 --version "$VERSION" \
42 --macos-host "$MACOS_HOST" \
43 --json
44
45echo "==> reindex"
46scorpiox-cli-botplugin reindex --json >/dev/null 2>&1 || true
47
48echo "==> check the target count (must be 6)"
49curl -s "https://dist.scorpiox.net/bot-plugins/$SLUG/latest.json" |
50 python3 -c 'import json,sys; d=json.load(sys.stdin); t=d.get("targets",{}); print("version", d.get("version"), "targets", len(t)); sys.exit(0 if len(t)==6 else 1)'