Skip to content

Commit c6a2a4e

Browse files
drernieclaude
andcommitted
Add make bump target for version bumping
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f252634 commit c6a2a4e

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ S3_BASE = s3://$(WRITE_BUCKET)/$(PROJECT)
1212
REPORT ?= ./build/reports/tests/test/index.html
1313

1414
.PHONY: all assemble clean test test-all check rebuild install package release verify fast \
15-
coverage verifyCoverage \
15+
coverage verifyCoverage bump \
1616
check-env pkg-test dyn-test s3-overlay s3-test s3-in s3-out \
1717
pkg-fail path-input deps refresh
1818

@@ -58,6 +58,13 @@ check-env:
5858
rebuild:
5959
./gradlew clean build --refresh-dependencies
6060

61+
# make bump -> patch bump (default)
62+
# make bump LEVEL=minor -> minor bump
63+
# make bump LEVEL=major -> major bump
64+
LEVEL ?= patch
65+
bump:
66+
./wf/bump-version.sh $(LEVEL)
67+
6168
test-all: clean test
6269

6370
install: assemble

wf/bump-version.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
LEVEL="${1:-patch}"
5+
case "$LEVEL" in
6+
patch|minor|major) ;;
7+
*) echo "Usage: $0 [patch|minor|major]" >&2; exit 1 ;;
8+
esac
9+
10+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11+
FILE="$ROOT/build.gradle"
12+
13+
OLD="$(grep "^version" "$FILE" | head -1 | awk -F"'" '{ print $2 }')"
14+
if [[ ! "$OLD" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
15+
echo "Cannot parse semver from '$OLD' in $FILE" >&2
16+
exit 1
17+
fi
18+
MAJOR="${BASH_REMATCH[1]}"
19+
MINOR="${BASH_REMATCH[2]}"
20+
PATCH="${BASH_REMATCH[3]}"
21+
22+
case "$LEVEL" in
23+
patch) PATCH=$((PATCH + 1)) ;;
24+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
25+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
26+
esac
27+
NEW="${MAJOR}.${MINOR}.${PATCH}"
28+
29+
sed -i.bak "s/^version = '${OLD}'\$/version = '${NEW}'/" "$FILE"
30+
rm "$FILE.bak"
31+
32+
cd "$ROOT"
33+
git add build.gradle
34+
git commit -m "Bump version: ${OLD} -> ${NEW}"
35+
36+
echo "Bumped $OLD -> $NEW and committed."

0 commit comments

Comments
 (0)