Adds .githooks/pre-commit (secret scan, large-file guard, fast tests), scripts/check-secrets.sh, scripts/agent-commit.sh, scripts/publish.sh and scripts/setup-hooks.sh so every work session leaves a verifiable commit.
45 lines
1.3 KiB
Bash
Executable file
45 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Publish the current commit to the configured public remote.
|
|
#
|
|
# Usage: scripts/publish.sh [REMOTE] [BRANCH]
|
|
# REMOTE defaults to origin
|
|
# BRANCH defaults to the current branch
|
|
#
|
|
# Refuses to push an unclean working tree or a failing test suite.
|
|
|
|
set -euo pipefail
|
|
|
|
root="$(git rev-parse --show-toplevel)"
|
|
cd "$root"
|
|
|
|
remote="${1:-origin}"
|
|
branch="${2:-$(git rev-parse --abbrev-ref HEAD)}"
|
|
|
|
if ! git remote get-url "$remote" >/dev/null 2>&1; then
|
|
echo "error: remote '$remote' is not configured." >&2
|
|
echo "add it once with: git remote add $remote <PUBLIC_REPO_URL>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
echo "error: working tree is not clean; commit first (scripts/agent-commit.sh)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "running fast test suite..."
|
|
bash installer/tests/run_tests.sh >/tmp/phoebus-publish-tests.log 2>&1 || {
|
|
echo "tests failed; see /tmp/phoebus-publish-tests.log" >&2
|
|
exit 1
|
|
}
|
|
|
|
if command -v cargo >/dev/null 2>&1 && [[ -f installer-rs/Cargo.toml ]]; then
|
|
echo "running Rust test suite..."
|
|
(cd installer-rs && cargo test --workspace) || {
|
|
echo "cargo tests failed" >&2
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
echo "pushing $branch to $remote ($(git remote get-url "$remote"))"
|
|
git push "$remote" "$branch"
|
|
echo "published: $(git log -1 --oneline)"
|