diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b341207..173a423 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,107 +12,66 @@ concurrency: cancel-in-progress: true jobs: - buildAndroid: - name: Build Android - runs-on: ubuntu-latest - if: github.event.pull_request.draft == false + build: + strategy: + matrix: + platform: [ android, ios, web, desktop ] + include: + - platform: android + os: ubuntu-latest + - platform: web + os: ubuntu-latest + - platform: ios + os: macos-latest + - platform: desktop + os: macos-latest + + runs-on: ${{ matrix.os }} steps: - # Code checkout - name: Checkout code - id: checkout_code uses: actions/checkout@v4 - # Setup Java and Gradle - name: Java and Gradle set up + if: matrix.platform != 'ios' uses: ./.github/workflows/setup/java-setup - # Grant execute permission for script - - name: Grant execute permission for script - id: grant_script_permission - shell: bash - run: chmod +x ./scripts/build_android.sh - - # Build and verify Android - - name: Build and verify Android - run: ./scripts/build_android.sh - - buildiOS: - name: Build iOS - runs-on: macos-latest - if: github.event.pull_request.draft == false - - steps: - # Code checkout - - name: Checkout code - id: checkout_code - uses: actions/checkout@v4 - - # Setup Java and Gradle - - name: Java and Gradle set up - uses: ./.github/workflows/setup/java-setup - - # Grant execute permission for script - - name: Grant execute permission for script - id: grant_script_permission - shell: bash - run: chmod +x ./scripts/build_android.sh - - # Setup iOS - name: iOS set up + if: matrix.platform == 'ios' uses: ./.github/workflows/setup/ios-setup - # Build iOS app - - name: Build iOS app - id: build_ios_debug - run: xcodebuild build -workspace sample/iosApp/iosApp.xcworkspace -configuration Debug -scheme iosApp -sdk iphonesimulator -verbose + # Android + - name: Grant execute permission for Android script + if: matrix.platform == 'android' + run: chmod +x ./scripts/build_android.sh - buildWeb: - name: Build Web - runs-on: ubuntu-latest - if: github.event.pull_request.draft == false + - name: Build Android + if: matrix.platform == 'android' + run: ./scripts/build_android.sh - steps: - # Code checkout - - name: Checkout code - id: checkout_code - uses: actions/checkout@v4 + # iOS + - name: Grant execute permission for iOS script + if: matrix.platform == 'ios' + run: chmod +x ./scripts/build_ios.sh - # Setup Java and Gradle - - name: Java and Gradle set up - uses: ./.github/workflows/setup/java-setup + - name: Build iOS + if: matrix.platform == 'ios' + run: ./scripts/build_ios.sh - # Grant execute permission for script - - name: Grant execute permission for script - id: grant_script_permission - shell: bash + # Web + - name: Grant execute permission for Web script + if: matrix.platform == 'web' run: chmod +x ./scripts/build_web.sh - # Build and verify Web - - name: Build and verify Web + - name: Build Web + if: matrix.platform == 'web' run: ./scripts/build_web.sh - buildMacOS: - name: Build MacOS - runs-on: macos-latest - if: github.event.pull_request.draft == false - - steps: - # Code checkout - - name: Checkout code - id: checkout_code - uses: actions/checkout@v4 - - # Setup Java and Gradle - - name: Java and Gradle set up - uses: ./.github/workflows/setup/java-setup - - # Grant execute permission for script - - name: Grant execute permission for script - id: grant_script_permission - shell: bash + # MacOS + - name: Grant execute permission for MacOS script + if: matrix.platform == 'desktop' run: chmod +x ./scripts/build_macos.sh - # Build and verify MacOS - - name: Build and verify MacOS + - name: Build MacOS + if: matrix.platform == 'desktop' run: ./scripts/build_macos.sh \ No newline at end of file diff --git a/scripts/build_android.sh b/scripts/build_android.sh index 1739f1a..a574ac4 100644 --- a/scripts/build_android.sh +++ b/scripts/build_android.sh @@ -1,15 +1,33 @@ #!/bin/bash +# Exit the script on any error +set -e + # Navigate to the root directory of the project cd "$(dirname "$0")/.." || exit # Create distributions folder in the root directory (if not already present) -mkdir -p distributions +mkdir -p distributions/android # Build Android App echo "Building Android App 📱" -./gradlew :sample:composeApp:assembleDebug +./gradlew :sample:composeApp:assembleDebug --console=plain --stacktrace + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "Android build successful." + + # Verify and copy the APK to the distributions folder + APK_PATH="sample/composeApp/build/outputs/apk/debug/composeApp-debug.apk" -# Verify and copy the APK to the distributions folder -echo "Verifying Android App" -cp sample/composeApp/build/outputs/apk/debug/composeApp-debug.apk distributions/jetlime-sample-android.apk + if [ -f "$APK_PATH" ]; then + cp "$APK_PATH" distributions/android/jetlime-sample-android.apk + echo "Android APK copied to distributions/android/jetlime-sample-android.apk" + else + echo "APK not found at expected path: $APK_PATH" + exit 1 + fi +else + echo "Android build failed." + exit 1 +fi \ No newline at end of file diff --git a/scripts/build_ios.sh b/scripts/build_ios.sh new file mode 100644 index 0000000..0b7343f --- /dev/null +++ b/scripts/build_ios.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Navigate to the root directory of the project +cd "$(dirname "$0")/.." || exit + +# Build iOS app using xcodebuild +xcodebuild build \ + -workspace sample/iosApp/iosApp.xcworkspace \ + -configuration Debug \ + -scheme iosApp \ + -sdk iphonesimulator \ + -verbose + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "iOS build successful." + + # Create distributions directory if it doesn't exist + mkdir -p distributions/ios + + # Copy the generated iOS build products to the distributions/ directory + BUILD_DIR=$(xcodebuild -workspace sample/iosApp/iosApp.xcworkspace \ + -scheme iosApp -configuration Debug -sdk iphonesimulator -showBuildSettings | grep -m1 " BUILT_PRODUCTS_DIR" | awk '{print $3}') + + if [ -d "$BUILD_DIR" ]; then + cp -R "$BUILD_DIR"/* distributions/ios/ + echo "iOS build copied to distributions/ios/ directory." + else + echo "Build directory not found!" + exit 1 + fi +else + echo "iOS build failed." + exit 1 +fi diff --git a/scripts/build_macos.sh b/scripts/build_macos.sh index 82210f7..f7db51d 100644 --- a/scripts/build_macos.sh +++ b/scripts/build_macos.sh @@ -1,17 +1,33 @@ #!/bin/bash +# Exit the script on any error +set -e + # Navigate to the root directory of the project cd "$(dirname "$0")/.." || exit # Create distributions folder in the root directory (if not already present) -mkdir -p distributions +mkdir -p distributions/macos # Build Mac Desktop App echo "Building Mac Desktop App 🖥️" -./gradlew :sample:composeApp:packageUberJarForCurrentOS +./gradlew :sample:composeApp:packageUberJarForCurrentOS --console=plain --stacktrace + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "Mac Desktop build successful." -# Verify and copy the JAR to the distributions folder -echo "Verifying Mac Desktop App" -cp "sample/composeApp/build/compose/jars/JetLime Samples-macos-arm64-1.0.0.jar" distributions/jetlime-sample-macos-x64.jar + # Verify and copy the JAR to the distributions folder + JAR_PATH="sample/composeApp/build/compose/jars/JetLime Samples-macos-arm64-1.0.0.jar" -echo "Mac Desktop app build and copied to distributions/jetlime-sample-macos-x64.jar" \ No newline at end of file + if [ -f "$JAR_PATH" ]; then + cp "$JAR_PATH" distributions/macos/jetlime-sample-macos-x64.jar + echo "Mac Desktop app copied to distributions/macos/jetlime-sample-macos-x64.jar" + else + echo "JAR not found at expected path: $JAR_PATH" + exit 1 + fi +else + echo "Mac Desktop build failed." + exit 1 +fi \ No newline at end of file diff --git a/scripts/build_web.sh b/scripts/build_web.sh index ac9fe20..a286296 100644 --- a/scripts/build_web.sh +++ b/scripts/build_web.sh @@ -1,16 +1,34 @@ #!/bin/bash +# Exit the script on any error +set -e + # Navigate to the root directory of the project cd "$(dirname "$0")/.." || exit # Build Web App echo "Building Web App 🌎" -./gradlew :sample:composeApp:wasmJsBrowserDistribution +./gradlew :sample:composeApp:wasmJsBrowserDistribution --console=plain --stacktrace + +# Check if the build was successful +if [ $? -eq 0 ]; then + echo "Web build successful." -# Create the distributions/jetlime-web folder in the root directory -mkdir -p distributions/jetlime-web + # Create the distributions/jetlime-web folder in the root directory + mkdir -p distributions/web -# Copy the production executable to the distributions folder -cp -r sample/composeApp/build/dist/wasmJs/productionExecutable/ distributions/jetlime-web/ + # Path to the production executable + WEB_EXECUTABLE_PATH="sample/composeApp/build/dist/wasmJs/productionExecutable/" -echo "Web app build and copied to distributions/jetlime-web" + # Verify and copy the production executable to the distributions folder + if [ -d "$WEB_EXECUTABLE_PATH" ]; then + cp -r "$WEB_EXECUTABLE_PATH" distributions/web/ + echo "Web app copied to distributions/web" + else + echo "Web build output not found at expected path: $WEB_EXECUTABLE_PATH" + exit 1 + fi +else + echo "Web build failed." + exit 1 +fi \ No newline at end of file