diff --git a/deploy.sh b/deploy.sh index 4be801a..b672833 100644 --- a/deploy.sh +++ b/deploy.sh @@ -14,7 +14,6 @@ declare -a steps=( "Run Tests:sh run_tests.sh" "Build Demo App:sh build_demo_app.sh" "Update Build Version:sh update_version.sh" - "Install Brew:sh install_homebrew.sh" "Create Git Release:sh git_release.sh" "Release Cocoapod:sh release_pod.sh" ) diff --git a/pubspec.yaml b/pubspec.yaml index 3f55f2e..667cf83 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: courier_flutter description: Inbox, Push Notifications and Preferences for Flutter -version: 2.4.1 +version: 3.0.0 homepage: https://courier.com environment: diff --git a/release.sh b/release.sh deleted file mode 100644 index ad7b247..0000000 --- a/release.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# Install Github CLI if needed -#brew install gh -#gh auth login -# -## Install yq for parsing yml -#brew install python-yq - -# Get the package version from the pubspec -PACKAGE_VERSION=$(yq .version pubspec.yaml | tr -d '"') -echo $PACKAGE_VERSION - -# Bump the version -git add . -git commit -m "Bump" -git push - -# Add the tag -git tag $PACKAGE_VERSION -git push --tags - -# gh release create -gh release create $PACKAGE_VERSION --generate-notes - -# Publish to pub.dev -flutter pub publish \ No newline at end of file diff --git a/build.sh b/scripts/build_demo_app.sh similarity index 85% rename from build.sh rename to scripts/build_demo_app.sh index 7aeab0f..aa86e3b 100644 --- a/build.sh +++ b/scripts/build_demo_app.sh @@ -1,11 +1,9 @@ #!/bin/bash # Navigate to the example directory -cd example || { echo "Failed to navigate to the example directory. Please ensure the path is correct."; exit 1; } +cd ../example || { echo "Failed to navigate to the example directory. Please ensure the path is correct."; exit 1; } echo "Navigated to the example directory." -sh ../dist.sh - # Build Android app bundle echo "🤖 Building Android app bundle..." flutter build appbundle diff --git a/scripts/git_release.sh b/scripts/git_release.sh new file mode 100644 index 0000000..4871476 --- /dev/null +++ b/scripts/git_release.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Change to the root directory +cd "$(dirname "$0")/.." + +# Define ANSI color codes +ORANGE='\033[0;33m' +NC='\033[0m' # No Color + +# Function to handle errors and exit +error_exit() { + echo -e "❌ Error: $1" >&2 + exit 1 +} + +# Function to get the package version from pubspec.yaml +get_package_version() { + local version=$(yq .version pubspec.yaml | tr -d '"') + echo "$version" +} + +# Function to get the current Git branch +get_current_branch() { + git rev-parse --abbrev-ref HEAD +} + +# Function to run git status +run_git_status() { + git status +} + +# Function to add all changes and commit with message including version +add_commit() { + local version="$1" + git add -A + git commit -m "🚀 $version" +} + +# Function to merge the current branch into master +merge_into_master() { + local branch=$(get_current_branch) + git checkout master + git merge --no-ff "$branch" + git push origin master + git checkout "$branch" +} + +# Function to install GitHub CLI if not already installed +install_gh_cli() { + if ! which gh >/dev/null 2>&1; then + echo -e "${ORANGE}⚠️ Installing GitHub CLI...${NC}" + brew install gh || error_exit "Failed to install GitHub CLI. Please install it manually and retry." + fi +} + +# Function to create GitHub release +create_github_release() { + local version="$1" + echo -e "${ORANGE}⚠️ Creating GitHub release for version $version...${NC}\n" + gh release create "$version" --notes "Release for version $version" + echo "✅ GitHub release $version created\n" +} + +# Main script execution +# Check if GitHub CLI is installed +install_gh_cli + +# Get the package version from pubspec.yaml +current_version=$(get_package_version) +echo "Current version is $current_version" + +# Ask for confirmation to merge into master with versioned commit +read -p "Merge into master and create release with commit: '🚀 $current_version'? (y/n): " confirmation + +if [[ $confirmation == "y" || $confirmation == "Y" ]]; then + # Perform the Git operations + run_git_status + add_commit "$current_version" + merge_into_master + + # Tag the new version + git tag "$current_version" + git push --tags + + # Create the GitHub release + create_github_release "$current_version" +else + echo "Merge and release process canceled." +fi \ No newline at end of file diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index b018cce..388c84f 100644 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -3,5 +3,36 @@ # Change to the root directory cd ../example || exit -# Run tests -flutter test integration_test/client_tests.dart \ No newline at end of file +# Function to run the tests with the selected device ID +run_tests() { + flutter test integration_test/client_tests.dart --device-id="$DEVICE_ID" + flutter test integration_test/shared_tests.dart --device-id="$DEVICE_ID" +} + +# Function to prompt the user to select a device and run the tests +select_device_and_run_tests() { + # List available devices + echo "Listing available devices..." + flutter devices + + # Prompt the user to enter the device ID + echo "Please enter the device ID to run the tests on:" + read -r DEVICE_ID + + # Run the tests with the selected device ID + run_tests + + # Ask the user if they want to rerun the tests + while true; do + echo "Do you want to rerun the tests or end the script? (r to rerun, e to exit):" + read -r REPLY + case $REPLY in + [Rr]* ) select_device_and_run_tests; break;; + [Ee]* ) echo "Exiting."; exit;; + * ) echo "Please answer 'r' to rerun or 'e' to exit.";; + esac + done +} + +# Start the process +select_device_and_run_tests \ No newline at end of file diff --git a/dist.sh b/scripts/update_version.sh similarity index 97% rename from dist.sh rename to scripts/update_version.sh index a6ec924..d21aaec 100644 --- a/dist.sh +++ b/scripts/update_version.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Change to the root directory +cd "$(dirname "$0")/.." + # Define ANSI color codes ORANGE='\033[0;33m' NC='\033[0m' # No Color