Created
January 4, 2026 14:31
-
-
Save p32929/09d6a1be3d6c07bb6b4ff07da4ee5d8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Build and collect APKs for Flutter apps | |
| # Usage: ./build-apks.sh | |
| set -e # Exit on error | |
| # Colors for output | |
| GREEN='\033[0;32m' | |
| BLUE='\033[0;34m' | |
| RED='\033[0;31m' | |
| NC='\033[0m' # No Color | |
| # Get current date in format: dec20-2025 | |
| DATE=$(date +"%b%d-%Y" | tr '[:upper:]' '[:lower:]') | |
| # Base directory | |
| BASE_DIR="/Users/mac/Documents/others/thr_" | |
| APKS_DIR="${BASE_DIR}/apks" | |
| # Define Flutter apps to build (add more here as needed) | |
| # Format: "directory_name:apk_prefix:Display Name" | |
| APPS=( | |
| "client_flutter:client:Client App" | |
| "trainer_flutter:trainer:Trainer App" | |
| ) | |
| echo -e "${BLUE}==================================${NC}" | |
| echo -e "${BLUE} Building Flutter APKs${NC}" | |
| echo -e "${BLUE} Date: ${DATE}${NC}" | |
| echo -e "${BLUE}==================================${NC}" | |
| echo "" | |
| # Create apks directory if it doesn't exist | |
| if [ ! -d "$APKS_DIR" ]; then | |
| echo -e "${GREEN}Creating apks directory...${NC}" | |
| mkdir -p "$APKS_DIR" | |
| fi | |
| # Track built APKs for final summary | |
| BUILT_APKS=() | |
| # Build each app | |
| for app in "${APPS[@]}"; do | |
| IFS=':' read -r dir prefix name <<< "$app" | |
| APP_DIR="${BASE_DIR}/${dir}" | |
| if [ ! -d "$APP_DIR" ]; then | |
| echo -e "${RED}✗ Directory not found: ${dir}${NC}" | |
| continue | |
| fi | |
| echo -e "${BLUE}Building ${name}...${NC}" | |
| cd "$APP_DIR" | |
| flutter build apk --debug | |
| # Find and copy APK | |
| APK_FILE=$(find build/app/outputs/flutter-apk -name "*.apk" | head -1) | |
| if [ -f "$APK_FILE" ]; then | |
| NEW_NAME="${prefix}-${DATE}.apk" | |
| cp "$APK_FILE" "${APKS_DIR}/${NEW_NAME}" | |
| echo -e "${GREEN}✓ ${name} APK built: ${NEW_NAME}${NC}" | |
| BUILT_APKS+=("${APKS_DIR}/${NEW_NAME}") | |
| else | |
| echo -e "${RED}✗ ${name} APK not found!${NC}" | |
| exit 1 | |
| fi | |
| echo "" | |
| done | |
| echo -e "${GREEN}==================================${NC}" | |
| echo -e "${GREEN} Build Complete!${NC}" | |
| echo -e "${GREEN}==================================${NC}" | |
| echo -e "${GREEN}APKs saved to: ${APKS_DIR}${NC}" | |
| echo "" | |
| # List all built APKs | |
| for apk in "${BUILT_APKS[@]}"; do | |
| ls -lh "$apk" | |
| done | |
| echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment