-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincrement_version.sh
More file actions
executable file
·93 lines (74 loc) · 3.44 KB
/
Copy pathincrement_version.sh
File metadata and controls
executable file
·93 lines (74 loc) · 3.44 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
#!/bin/bash
# increment_version.sh
#
# DEPRECATED: Versioning is now handled automatically by release-please.
# Use conventional commits (feat:, fix:, etc.) and merge to main.
# release-please will create a Release PR with the correct version bumps.
#
# This script is kept for local development convenience only.
# It increments version numbers across ALL GoudEngine project files:
# - goud_engine/Cargo.toml (source of truth)
# - sdks/csharp/GoudEngine.csproj
# - sdks/typescript/package.json
# - sdks/typescript/native/Cargo.toml
# - sdks/rust/Cargo.toml
# - codegen/goud_sdk.schema.json
# - All .csproj files in /examples directory
#
# Usage:
# ./increment_version.sh # Increments patch version (0.0.X)
# ./increment_version.sh --major # Increments major version (X.0.0)
# ./increment_version.sh --minor # Increments minor version (0.X.0)
# Function to increment version based on flag
increment_version() {
local version=$1
local flag=$2
IFS='.' read -r major minor patch <<< "$version"
case $flag in
"--major")
major=$((major + 1))
minor=0
patch=0
;;
"--minor")
minor=$((minor + 1))
patch=0
;;
*)
patch=$((patch + 1))
;;
esac
echo "$major.$minor.$patch"
}
# Portable in-place sed. GNU sed uses `-i`; BSD/macOS sed requires `-i ''`.
# Detect once and expand SED_INPLACE as the command prefix.
if sed --version >/dev/null 2>&1; then
SED_INPLACE=(sed -i)
else
SED_INPLACE=(sed -i '')
fi
# Get the flag if provided
FLAG=$1
# Read current version from Cargo.toml
CURRENT_VERSION=$(grep '^version = ' goud_engine/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$FLAG")
echo "Updating version from $CURRENT_VERSION to $NEW_VERSION"
# Update Cargo.toml
"${SED_INPLACE[@]}" "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" goud_engine/Cargo.toml
# Update GoudEngine.csproj
"${SED_INPLACE[@]}" "s/<Version>$CURRENT_VERSION<\/Version>/<Version>$NEW_VERSION<\/Version>/" sdks/csharp/GoudEngine.csproj
# Update all .csproj files in examples directory - handle both formats
find examples -name "*.csproj" -type f -exec "${SED_INPLACE[@]}" -e "s/<PackageReference Include=\"GoudEngine\" Version=\"[0-9]*\.[0-9]*\.[0-9]*\" \/>/<PackageReference Include=\"GoudEngine\" Version=\"$NEW_VERSION\" \/>/" -e "s/<PackageReference Include=\"GoudEngine\" Version=\"[0-9]*\.[0-9]*\.[0-9]*\">/<PackageReference Include=\"GoudEngine\" Version=\"$NEW_VERSION\">/" {} \;
# Update codegen schema version
"${SED_INPLACE[@]}" "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"$NEW_VERSION\"/" codegen/goud_sdk.schema.json
# Update TypeScript package.json version
"${SED_INPLACE[@]}" "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"$NEW_VERSION\"/" sdks/typescript/package.json
# Update TypeScript native Cargo.toml version
"${SED_INPLACE[@]}" "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" sdks/typescript/native/Cargo.toml
# Update Rust SDK Cargo.toml version
"${SED_INPLACE[@]}" "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" sdks/rust/Cargo.toml
# Update Rust SDK dependency version constraint
"${SED_INPLACE[@]}" "s/version = \"=$CURRENT_VERSION\"/version = \"=$NEW_VERSION\"/" sdks/rust/Cargo.toml
# Update version.txt (used by release-please)
echo "$NEW_VERSION" > version.txt
echo "Version update complete!"