-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathbump.sh
More file actions
executable file
·50 lines (37 loc) · 1.53 KB
/
bump.sh
File metadata and controls
executable file
·50 lines (37 loc) · 1.53 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
#!/usr/bin/env bash
set -e
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../
# Check if exactly one argument is provided and is one of the allowed values.
if [ "$#" -ne 1 ]; then
echo "Usage: $0 [patch|minor|major]"
exit 1
fi
version_type="$1"
if [[ "$version_type" != "patch" && "$version_type" != "minor" && "$version_type" != "major" ]]; then
echo "Invalid version type: $version_type"
echo "Usage: $0 [patch|minor|major]"
exit 1
fi
# Bump version in the ts package using pnpm
cd ts
# Get the old version from package.json
old_version=$(node -p "require('./package.json').version")
echo "Old version: $old_version"
pnpm version "$version_type"
# Get the new version from package.json
new_version=$(node -p "require('./package.json').version")
echo "New version: $new_version"
# Update the version in src/constants.ts
sed -i.bak "s/export const VERSION = '.*';/export const VERSION = '$new_version';/g" src/constants.ts
# Update the version in src/flowerintelligence.test.ts
sed -i.bak "s/VERSION: '.*',/VERSION: '$new_version',/g" src/flowerintelligence.test.ts
# Remove the temporary backup files created by sed
rm src/constants.ts.bak src/flowerintelligence.test.ts.bak
# Update all examples/*/package.json files to set "@flwr/flwr" to the old version.
for pkg in examples/*/package.json; do
echo "Updating $pkg with version ^$old_version"
sed -i.bak "s/\"@flwr\/flwr\": \"\^[0-9]*\.[0-9]*\.[0-9]*\",/\"@flwr\/flwr\": \"^$old_version\",/g" "$pkg"
rm "$pkg.bak"
done
cd ..
echo "Version updated successfully!"