Files
computer-playbook/scripts/github/release/guard.sh
T
kevinveenbirkenbachandClaude Opus 4.7 f9147e4486 refactor(scripts/github): split helpers into responsibility subfolders
Group the shell helpers under scripts/github/ into five subfolders
that match how the workflow files consume them:

  runner/   host-runner hygiene (disk, swap, Docker daemon, diagnostics)
  cancel/   run cancellation on PR-close and branch-delete events
  resolve/  derivation of workflow inputs and outputs from repo state
  update/   scheduled Update: Versions pipeline
  release/  release-time gates

Drop the now-redundant subfolder prefix from each filename, e.g.
dump_runner_state.sh becomes dump_state.sh and cancel_pull_request_runs.sh
becomes pull_request_runs.sh. Each subfolder carries a README that
describes its scope per documentation.md rules; the top-level README
points at the subfolders without inventorying files.

Propagate the new paths through ten workflow files, three docs
(workflow.md, pipeline.md, secrets.md), and two tests. Fix a real
runtime bug in enlarge_swap.sh, which still referenced the
pre-rename dump_runner_state.sh path. Extend the inline-block-size
lint hint to describe the new subfolder convention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 00:50:26 +02:00

29 lines
767 B
Bash
Executable File

#!/usr/bin/env bash
#
# Guard the version-release pipeline: only allow when the commit the
# version tag points at is contained in origin/main. Sets `allowed` on
# GITHUB_OUTPUT to true / false.
#
# Usage:
# guard.sh
# (reads VERSION_TAG from env; writes to GITHUB_OUTPUT)
set -euo pipefail
if [[ -z "${VERSION_TAG:-}" ]]; then
echo "allowed=false" >>"$GITHUB_OUTPUT"
echo "⛔ No version tag detected for this commit"
exit 0
fi
tag="$VERSION_TAG"
tag_sha="$(git rev-list -n 1 "$tag")"
echo "Tag: ${tag} -> ${tag_sha}"
if git merge-base --is-ancestor "$tag_sha" "origin/main"; then
echo "allowed=true" >>"$GITHUB_OUTPUT"
echo "✅ Tag commit is on origin/main"
else
echo "allowed=false" >>"$GITHUB_OUTPUT"
echo "⛔ Tag commit is NOT on origin/main"
fi