Add --minor flag to release.sh for forced minor bumps

Allows forcing a minor version bump even when abidiff passes,
for behavioral breaking changes that don't break ABI.
This commit is contained in:
yhirose
2026-05-10 13:24:57 +09:00
parent fbb031ed85
commit e8e652824b

View File

@@ -2,10 +2,12 @@
# #
# Release a new version of cpp-httplib. # Release a new version of cpp-httplib.
# #
# Usage: ./release.sh [--run] # Usage: ./release.sh [--run] [--minor]
# #
# By default, runs in dry-run mode (no changes made). # By default, runs in dry-run mode (no changes made).
# Pass --run to actually update files, commit, tag, and push. # Pass --run to actually update files, commit, tag, and push.
# Pass --minor to force a minor bump even when ABI is unchanged
# (use this for behavioral breaking changes that don't break ABI).
# #
# This script: # This script:
# 1. Reads the current version from httplib.h # 1. Reads the current version from httplib.h
@@ -14,21 +16,30 @@
# 4. Determines the next version automatically: # 4. Determines the next version automatically:
# - abidiff passed → patch bump (e.g., 0.38.0 → 0.38.1) # - abidiff passed → patch bump (e.g., 0.38.0 → 0.38.1)
# - abidiff failed → minor bump (e.g., 0.38.1 → 0.39.0) # - abidiff failed → minor bump (e.g., 0.38.1 → 0.39.0)
# - --minor passed → forces minor bump regardless of abidiff
# 5. Updates httplib.h and docs-src/config.toml # 5. Updates httplib.h and docs-src/config.toml
# 6. Commits, tags (vX.Y.Z), and pushes # 6. Commits, tags (vX.Y.Z), and pushes
set -euo pipefail set -euo pipefail
DRY_RUN=1 DRY_RUN=1
if [ "${1:-}" = "--run" ]; then FORCE_MINOR=0
DRY_RUN=0 while [ $# -gt 0 ]; do
shift case "$1" in
fi --run)
DRY_RUN=0
if [ $# -ne 0 ]; then shift
echo "Usage: $0 [--run]" ;;
exit 1 --minor)
fi FORCE_MINOR=1
shift
;;
*)
echo "Usage: $0 [--run] [--minor]"
exit 1
;;
esac
done
# --- Step 1: Read current version from httplib.h --- # --- Step 1: Read current version from httplib.h ---
CURRENT_VERSION=$(sed -n 's/^#define CPPHTTPLIB_VERSION "\([^"]*\)"/\1/p' httplib.h) CURRENT_VERSION=$(sed -n 's/^#define CPPHTTPLIB_VERSION "\([^"]*\)"/\1/p' httplib.h)
@@ -51,8 +62,7 @@ HEAD_SHORT=$(git rev-parse --short HEAD)
echo " Latest commit: $HEAD_SHORT" echo " Latest commit: $HEAD_SHORT"
# Fetch all workflow runs for the HEAD commit # Fetch all workflow runs for the HEAD commit
RUNS=$(gh run list --json name,conclusion,headSha \ RUNS=$(gh run list --commit "$HEAD_SHA" --json name,conclusion,headSha)
--jq "[.[] | select(.headSha == \"$HEAD_SHA\")]")
NUM_RUNS=$(echo "$RUNS" | jq 'length') NUM_RUNS=$(echo "$RUNS" | jq 'length')
@@ -95,7 +105,12 @@ fi
echo " All non-abidiff CI checks passed." echo " All non-abidiff CI checks passed."
# --- Step 4: Determine new version --- # --- Step 4: Determine new version ---
if [ "$ABIDIFF_PASSED" -eq 1 ]; then if [ "$FORCE_MINOR" -eq 1 ] && [ "$ABIDIFF_PASSED" -eq 1 ]; then
NEW_MINOR=$((V_MINOR + 1))
NEW_VERSION="$V_MAJOR.$NEW_MINOR.0"
echo ""
echo "==> abidiff passed but --minor specified → forced minor bump"
elif [ "$ABIDIFF_PASSED" -eq 1 ]; then
NEW_PATCH=$((V_PATCH + 1)) NEW_PATCH=$((V_PATCH + 1))
NEW_VERSION="$V_MAJOR.$V_MINOR.$NEW_PATCH" NEW_VERSION="$V_MAJOR.$V_MINOR.$NEW_PATCH"
echo "" echo ""
@@ -104,7 +119,11 @@ else
NEW_MINOR=$((V_MINOR + 1)) NEW_MINOR=$((V_MINOR + 1))
NEW_VERSION="$V_MAJOR.$NEW_MINOR.0" NEW_VERSION="$V_MAJOR.$NEW_MINOR.0"
echo "" echo ""
echo "==> abidiff failed → minor bump" if [ "$FORCE_MINOR" -eq 1 ]; then
echo "==> abidiff failed → minor bump (--minor also specified)"
else
echo "==> abidiff failed → minor bump"
fi
fi fi
VERSION_HEX=$(printf "0x%02x%02x%02x" "${NEW_VERSION%%.*}" "$(echo "$NEW_VERSION" | cut -d. -f2)" "${NEW_VERSION##*.}") VERSION_HEX=$(printf "0x%02x%02x%02x" "${NEW_VERSION%%.*}" "$(echo "$NEW_VERSION" | cut -d. -f2)" "${NEW_VERSION##*.}")