Skip to content

Commit 7106a6b

Browse files
committed
Add bump version and commit
1 parent 94d31c9 commit 7106a6b

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Diff for: justfile

+3
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,7 @@ uml PATH:
8585
PLANTUML_LIMIT_SIZE=16384 plantuml sources.txt && open sources.png
8686
rm sources.cmapx
8787

88+
bump-version:
89+
@sh ./scripts/bump-version-and-commit.sh patch
90+
8891
mod core

Diff for: scripts/bump-version-and-commit.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
bump=${1:-patch}
5+
file="Gem.xcodeproj/project.pbxproj"
6+
7+
version=$(sh ./scripts/bump-version.sh "$bump")
8+
git add "$file"
9+
git commit -m "Bump to $version" > /dev/null
10+
11+
echo "✅ Version bumped to $version and changes committed."

Diff for: scripts/bump-version.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
file="Gem.xcodeproj/project.pbxproj"
5+
bump=${1:-patch} # default to patch
6+
7+
version=$(grep -oE "MARKETING_VERSION = [0-9]+\.[0-9]+\.[0-9]+;" "$file" | head -n1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")
8+
if [[ -z "$version" ]]; then
9+
echo "❌ No MARKETING_VERSION found in $file" >&2
10+
exit 1
11+
fi
12+
13+
IFS="." read -r major minor patch <<< "$version"
14+
15+
case "$bump" in
16+
major) major=$((major + 1)); minor=0; patch=0 ;;
17+
minor) minor=$((minor + 1)); patch=0 ;;
18+
patch) patch=$((patch + 1)) ;;
19+
*) echo "❌ Invalid bump type: $bump" >&2; exit 1 ;;
20+
esac
21+
22+
new_version="${major}.${minor}.${patch}"
23+
sed -i '' "s/MARKETING_VERSION = $version;/MARKETING_VERSION = $new_version;/g" "$file"
24+
25+
echo "$new_version"

0 commit comments

Comments
 (0)