11#! /usr/bin/env bash
2+
3+ if [ -z " ${BASH_VERSION:- } " ]; then
4+ echo " release.sh must be run with bash; use scripts/release.sh or bash scripts/release.sh" >&2
5+ exit 2
6+ fi
7+
28set -euo pipefail
39
410# Runs the same local gates used before publishing, then optionally commits,
@@ -10,6 +16,19 @@ DRY_RUN=1
1016WAIT_PAGES=1
1117COMMIT_MESSAGE=" "
1218
19+ export GIT_EDITOR=true
20+ export GIT_SEQUENCE_EDITOR=true
21+ export GIT_MERGE_AUTOEDIT=no
22+ export GH_PROMPT_DISABLED=1
23+
24+ # Runs Git without opening an editor or interactive prompts.
25+ git_cmd () {
26+ git \
27+ -c core.editor=true \
28+ -c sequence.editor=true \
29+ " $@ "
30+ }
31+
1332# Prints release script usage.
1433usage () {
1534 cat << 'EOF '
6483cd " ${ROOT_DIR} "
6584
6685VERSION=" $( sed -n ' s/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1) "
67- BRANCH=" $( git branch --show-current) "
86+ BRANCH=" $( git_cmd branch --show-current) "
6887
6988if [[ -z " ${COMMIT_MESSAGE} " ]]; then
7089 COMMIT_MESSAGE=" Release ${VERSION} "
@@ -80,7 +99,7 @@ scripts/publish-crate.sh --prepare-only --allow-dirty
8099cargo fmt --check
81100cargo clippy --all-targets --all-features -- -D warnings
82101cargo test
83- git diff --check
102+ git_cmd diff --check
84103
85104if (( DRY_RUN)) ; then
86105 scripts/publish-crate.sh --dry-run --allow-dirty --no-bump
@@ -89,14 +108,14 @@ if ((DRY_RUN)); then
89108 exit 0
90109fi
91110
92- if [[ -n " $( git status --porcelain) " ]]; then
93- git add -A
94- git -c core.editor=true commit -m " ${COMMIT_MESSAGE} "
111+ if [[ -n " $( git_cmd status --porcelain) " ]]; then
112+ git_cmd add -A
113+ git_cmd commit --no-edit -m " ${COMMIT_MESSAGE} "
95114else
96115 echo " working tree is clean; no commit created"
97116fi
98117
99- git push
118+ git_cmd push
100119
101120if (( WAIT_PAGES)) ; then
102121 if command -v gh > /dev/null 2>&1 ; then
0 commit comments