Skip to content

Commit d56340d

Browse files
committed
Update release.sh
1 parent d08b6b9 commit d56340d

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

release.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
# Function to get current version from package.json
43
get_current_version() {
54
local package_json=$1
65
if [ -f "$package_json" ]; then
@@ -11,7 +10,6 @@ get_current_version() {
1110
fi
1211
}
1312

14-
# Function to get package name from package.json
1513
get_package_name() {
1614
local package_json=$1
1715
if [ -f "$package_json" ]; then
@@ -22,7 +20,12 @@ get_package_name() {
2220
fi
2321
}
2422

25-
# Function to update version
23+
if [ -n "$(git status --porcelain)" ]; then
24+
echo "Error: There are uncommitted changes in the working directory"
25+
echo "Please commit or stash these changes before proceeding"
26+
exit 1
27+
fi
28+
2629
update_version() {
2730
local package_dir=$1
2831
local version_type=$2
@@ -44,28 +47,23 @@ update_version() {
4447
esac
4548
}
4649

47-
# Main script
4850
echo "Starting package version management..."
4951

50-
# Get root package version
5152
root_package_json="packages/laravel-echo/package.json"
5253
current_version=$(get_current_version "$root_package_json")
5354
echo ""
5455
echo "Current version: $current_version"
5556
echo ""
5657

57-
# Get version type once
5858
read -p "Update version? (patch/minor/major): " version_type
5959
echo ""
6060

61-
# Iterate through packages directory
6261
for package_dir in packages/*; do
6362
if [ -d "$package_dir" ]; then
6463
echo "Updating version for $package_dir"
6564

6665
cd $package_dir
6766

68-
# Update version
6967
update_version "$package_dir" "$version_type"
7068

7169
cd ../..
@@ -74,22 +72,36 @@ for package_dir in packages/*; do
7472
fi
7573
done
7674

77-
# Get new version from root package
7875
new_version=$(get_current_version "$root_package_json")
7976

80-
# Install dependencies
8177
echo "Updating lock file..."
8278
pnpm i
8379

84-
# Create single git tag
80+
echo "Staging package.json files..."
81+
git add "**/package.json"
82+
echo ""
83+
84+
echo "Committing version changes..."
85+
git commit -m "v$new_version"
86+
echo ""
87+
8588
echo ""
8689
echo "Creating git tag: v$new_version"
8790
git tag "v$new_version"
8891
echo ""
8992

9093
echo "Running release process..."
9194
echo ""
92-
pnpm -r run release
95+
96+
for package_dir in packages/*; do
97+
if [ -d "$package_dir" ]; then
98+
echo "Releasing $package_dir"
99+
cd $package_dir
100+
pnpm run release
101+
cd ../..
102+
echo ""
103+
fi
104+
done
93105

94106
# Echo joke
95107
echo "Released! (Released!) (Released!)"

0 commit comments

Comments
 (0)