Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 50 additions & 15 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#!/bin/bash
set -euo pipefail

$REPO="laravel/stream"
REPO="laravel/stream"
BRANCH="main"

# Ensure we are on correct branch and the working tree is clean
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "$BRANCH" ]; then
echo "Error: must be on $BRANCH branch (current: $CURRENT_BRANCH)" >&2
exit 1
fi

if [ -n "$(git status --porcelain)" ]; then
echo "Error: working tree is not clean. Commit or stash changes before releasing." >&2
git status --porcelain
exit 1
fi

get_current_version() {
local package_json=$1
Expand Down Expand Up @@ -51,32 +66,52 @@ fi

git pull

echo "Starting package version management..."

root_package_json="packages/react/package.json"
current_version=$(get_current_version "$root_package_json")
ROOT_PACKAGE_JSON="packages/react/package.json"
CURRENT_VERSION=$(get_current_version "$ROOT_PACKAGE_JSON")
echo ""
echo "Current version: $current_version"
echo "Current version: $CURRENT_VERSION"
echo ""

read -p "Update version? (patch/minor/major): " version_type
echo ""
echo "Select version bump type:"
echo "1) patch (bug fixes)"
echo "2) minor (new features)"
echo "3) major (breaking changes)"
echo

read -p "Enter your choice (1-3): " choice

case $choice in
1)
RELEASE_TYPE="patch"
;;
2)
RELEASE_TYPE="minor"
;;
3)
RELEASE_TYPE="major"
;;
*)
echo "❌ Invalid choice. Exiting."
exit 1
;;
esac

for package_dir in packages/*; do
if [ -d "$package_dir" ]; then
echo "Updating version for $package_dir"

cd $package_dir

update_version "$package_dir" "$version_type"
update_version "$package_dir" "$RELEASE_TYPE"

cd ../..

echo ""
fi
done

new_version=$(get_current_version "$root_package_json")
NEW_VERSION=$(get_current_version "$ROOT_PACKAGE_JSON")
TAG="v$NEW_VERSION"

echo "Updating lock file..."
pnpm i
Expand All @@ -86,13 +121,13 @@ echo "Staging package.json files..."
git add "**/package.json"
echo ""

git commit -m "$new_version"
git tag -a "$new_version" -m "$new_version"
git commit -m "$TAG"
git tag -a "$TAG" -m "$TAG"
git push
git push --tags

gh release create "$new_version" --generate-notes
gh release create "$TAG" --generate-notes --fail-on-no-commits

echo ""
echo "✅ Release $new_version completed successfully, publishing kicked off in CI."
echo "🔗 https://github.com/$REPO/releases/tag/$new_version"
echo "✅ Release $TAG completed successfully, publishing kicked off in CI."
echo "🔗 https://github.com/$REPO/releases/tag/$TAG"