提交记录修改release.sh+10 −4看文件
修改tests/16-setup.sh+11 −1看文件
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | # ./release.sh X.Y.Z check, then tag, push and publish |
| 6 | 6 | # ./release.sh X.Y.Z --dry-run run every check, change nothing |
| 7 | 7 | # ./release.sh X.Y.Z --yes no confirmation prompt |
| 8 | 新增:# ./release.sh X.Y.Z --bypass-checks without waiting for the test workflow | |
| 8 | 9 | # ./release.sh notes X.Y.Z print that version's CHANGELOG.md section |
| 9 | 10 | # |
| 10 | 11 | # It bumps and commits nothing. First, in an ordinary commit on main: set |
| @@ -40,7 +41,7 @@ warn() { printf '%s!%s %s\n' "$c_y" "$c_0" "$*"; } | ||
| 40 | 41 | die() { printf '%s✗%s %s\n' "$c_r" "$c_0" "$*" >&2; exit 1; } |
| 41 | 42 | |
| 42 | 43 | usage() { |
| 43 | 删除: sed -n '5,8p' "$0" | sed 's/^# \{0,1\}//' >&2 | |
| 44 | 新增: sed -n '5,9p' "$0" | sed 's/^# \{0,1\}//' >&2 | |
| 44 | 45 | exit 2 |
| 45 | 46 | } |
| 46 | 47 | |
| @@ -88,11 +89,12 @@ fi | ||
| 88 | 89 | VERSION="$1"; shift |
| 89 | 90 | valid_version "$VERSION" || die "not a version: '$VERSION' (expected X.Y.Z)" |
| 90 | 91 | TAG="v$VERSION" |
| 91 | 删除:DRY_RUN=""; ASSUME_YES="" | |
| 92 | 新增:DRY_RUN=""; ASSUME_YES=""; BYPASS_CHECKS="" | |
| 92 | 93 | while [ $# -gt 0 ]; do |
| 93 | 94 | case "$1" in |
| 94 | 95 | --dry-run) DRY_RUN=1 ;; |
| 95 | 96 | --yes) ASSUME_YES=1 ;; |
| 97 | 新增: --bypass-checks) BYPASS_CHECKS=1 ;; | |
| 96 | 98 | *) usage ;; |
| 97 | 99 | esac |
| 98 | 100 | shift |
| @@ -176,12 +178,16 @@ ok "CHANGELOG.md has a $VERSION section ($(printf '%s\n' "$NOTES" | wc -l | tr - | ||
| 176 | 178 | |
| 177 | 179 | # --- 3. tests ------------------------------------------------------------------ |
| 178 | 180 | # CI is the authority: it runs bash 3.2, which this machine may lack. |
| 181 | 新增:# --bypass-checks skips the workflow only: the checks above decide what the | |
| 182 | 新增:# tag and the release are, and still apply. | |
| 179 | 183 | echo "Checking the tests" |
| 180 | 184 | ci="skipped" |
| 181 | 删除:[ -z "$GH" ] || ci="$(gh run list --workflow test.yml --commit "$head" --limit 1 \ | |
| 185 | 新增:[ -z "$GH" ] || [ -n "$BYPASS_CHECKS" ] || ci="$(gh run list --workflow test.yml --commit "$head" --limit 1 \ | |
| 182 | 186 | --json status,conclusion --jq '.[0] | "\(.status) \(.conclusion)"' 2>/dev/null || true)" |
| 183 | 187 | case "$ci" in |
| 184 | 删除: skipped) warn "the test workflow on ${head:0:12} was not checked (no gh)" ;; | |
| 188 | 新增: skipped) | |
| 189 | 新增: if [ -n "$BYPASS_CHECKS" ]; then warn "the test workflow on ${head:0:12} was not checked (--bypass-checks)" | |
| 190 | 新增: else warn "the test workflow on ${head:0:12} was not checked (no gh)"; fi ;; | |
| 185 | 191 | "completed success") ok "the test workflow passed on ${head:0:12}" ;; |
| 186 | 192 | "") die "no test workflow run for ${head:0:12}: push and wait for CI" ;; |
| 187 | 193 | completed*) die "the test workflow did not pass on ${head:0:12} ($ci)" ;; |
| @@ -95,7 +95,7 @@ if command -v git >/dev/null 2>&1; then | ||
| 95 | 95 | cat > "$RB/gh" <<STUB |
| 96 | 96 | #!/bin/sh |
| 97 | 97 | case "\$1 \$2" in |
| 98 | 删除: "run list") echo "completed success" ;; | |
| 98 | 新增: "run list") echo "\${REL_CI:-completed success}" ;; | |
| 99 | 99 | "release view") [ -e "$SB/rel-released" ] ;; |
| 100 | 100 | "repo view") echo "o/r" ;; |
| 101 | 101 | esac |
| @@ -119,6 +119,16 @@ STUB | ||
| 119 | 119 | case "$(AGENT_VM_TAP="$SB/no-tap" relrun)" in *"Checking the repository"*) fail "release.sh: the formula is checked after the repository" ;; *) pass "release.sh: a missing formula stops it first" ;; esac ;; |
| 120 | 120 | *) fail "release.sh: missing formula: $(AGENT_VM_TAP="$SB/no-tap" relrun)" ;; |
| 121 | 121 | esac |
| 122 | 新增: # A failed workflow stops the run; --bypass-checks goes on, saying so. | |
| 123 | 新增: case "$(REL_CI="completed failure" relrun; echo "rc=$?")" in | |
| 124 | 新增: *"did not pass"*"rc=1") pass "release.sh: a failed test workflow stops it" ;; | |
| 125 | 新增: *) fail "release.sh: failed workflow: $(REL_CI="completed failure" relrun)" ;; | |
| 126 | 新增: esac | |
| 127 | 新增: out="$( cd "$RR" && REL_CI="completed failure" PATH="$RB:$PATH" bash ./release.sh "$AGENT_VM_VERSION" --dry-run --bypass-checks 2>&1 )" | |
| 128 | 新增: case "$out" in | |
| 129 | 新增: *"not checked (--bypass-checks)"*"dry run complete"*) pass "release.sh --bypass-checks: the workflow is skipped, with a warning" ;; | |
| 130 | 新增: *) fail "release.sh --bypass-checks: $out" ;; | |
| 131 | 新增: esac | |
| 122 | 132 | touch "$SB/rel-released" |
| 123 | 133 | case "$(relrun)" in *"tag v$AGENT_VM_VERSION already exists"*) pass "release.sh: a released tag is still refused" ;; *) fail "release.sh: a released tag was not refused" ;; esac |
| 124 | 134 | # The tag made here but never pushed: resumed too, and pushed before the |

