-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·114 lines (99 loc) · 2.77 KB
/
build.sh
File metadata and controls
executable file
·114 lines (99 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
bump_version() {
local bump_type="$1"
# Read current version from Cargo.toml
local current_version=$(grep '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
if [ -z "$current_version" ]; then
echo "Error: Could not find version in Cargo.toml"
exit 1
fi
# Parse version into parts (x.y.z)
IFS='.' read -ra VERSION_PARTS <<< "$current_version"
local major="${VERSION_PARTS[0]}"
local minor="${VERSION_PARTS[1]}"
local patch="${VERSION_PARTS[2]}"
# Increment based on bump type
case "$bump_type" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Error: Unknown bump type: $bump_type (must be major, minor, or patch)"
exit 1
;;
esac
local new_version="${major}.${minor}.${patch}"
echo "Bumping $bump_type version from $current_version to $new_version"
# Update Cargo.toml
sed -i '' "s/^version = \".*\"/version = \"$new_version\"/" Cargo.toml
# Update Package.swift
sed -i '' "s/let tag = \"v.*\"/let tag = \"v$new_version\"/" Package.swift
# Update gradle.properties
sed -i '' "s/^version=.*/version=$new_version/" bindings/android/gradle.properties
echo "Version bumped to $new_version in all files"
}
BUILD_TARGET=""
DO_RELEASE=false
BUMP_TYPE="patch"
while [[ $# -gt 0 ]]; do
case $1 in
-r|--release)
DO_RELEASE=true
shift
;;
--major|-M)
BUMP_TYPE="major"
shift
;;
--minor|-m)
BUMP_TYPE="minor"
shift
;;
--patch|-p)
BUMP_TYPE="patch"
shift
;;
ios|android|python|all)
BUILD_TARGET="$1"
shift
;;
*)
echo "Usage: $0 [-r|--release] [--major|-M|--minor|-m|--patch|-p] {ios|android|python|all}"
echo " Version bump defaults to patch if --release is specified"
exit 1
;;
esac
done
# Bump version if release flag is set
if [ "$DO_RELEASE" = true ]; then
bump_version "$BUMP_TYPE"
fi
# Build based on target
case "$BUILD_TARGET" in
"ios")
./build_ios.sh
;;
"android")
./build_android.sh
;;
"python")
./build_python.sh
;;
"all")
./build_ios.sh && ./build_android.sh && ./build_python.sh
;;
*)
echo "Usage: $0 [-r|--release] [--major|-M|--minor|-m|--patch|-p] {ios|android|python|all}"
echo " Version bump defaults to patch if --release is specified"
exit 1
;;
esac