Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JkYTqsvYu6AYr9yQ3Q4Nt6
25 lines
1.8 KiB
Shell
Executable file
25 lines
1.8 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# The Composer package jumphp/engine (https://git.jumphp.net/jumphp/engine): the engine/ folder of a JumPHP tag, copied as
|
|
# one commit and tagged the same, so `composer require jumphp/engine` follows JumPHP's releases.
|
|
# tools/engine-split.sh v0.5.74 (after `gh release create v0.5.74`; the tag must exist on origin)
|
|
# Never moves an existing tag (AGENTS.md rule 13): a tag already there stops the script.
|
|
set -euo pipefail
|
|
tag="${1:?usage: tools/engine-split.sh vX.Y.Z}"
|
|
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "not a version tag: $tag" >&2; exit 1; }
|
|
root="$(cd "$(dirname "$0")/.." && pwd)"
|
|
remote="${JUMPHP_ENGINE_REMOTE:-https://git.jumphp.net/jumphp/engine.git}"
|
|
git -C "$root" fetch -q origin "refs/tags/$tag:refs/tags/$tag" 2>/dev/null || true # this tag only (old local tags may differ)
|
|
git -C "$root" rev-parse -q --verify "refs/tags/$tag" >/dev/null || { echo "$tag is not a tag of JumPHP (gh release create first)" >&2; exit 1; }
|
|
if git ls-remote --exit-code --tags "$remote" "refs/tags/$tag" >/dev/null 2>&1; then
|
|
echo "$tag already exists on $remote: nothing to do (a tag is never moved)"; exit 0
|
|
fi
|
|
work="$(mktemp -d)"; trap 'rm -rf "$work"' EXIT
|
|
git clone -q "$remote" "$work/engine"
|
|
find "$work/engine" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
|
git -C "$root" archive "$tag" engine | tar -x --strip-components=1 -C "$work/engine"
|
|
git -C "$work/engine" add -A
|
|
git -C "$work/engine" commit -q -m "jumphp/engine ${tag#v}: the engine/ folder of JumPHP $tag" || echo "(no change in engine/ since the last tag)"
|
|
git -C "$work/engine" tag "$tag"
|
|
git -C "$work/engine" push -q origin HEAD
|
|
git -C "$work/engine" push -q origin "$tag"
|
|
echo "jumphp/engine $tag: $(git ls-remote --tags "$remote" "refs/tags/$tag" | cut -c1-12)"
|