airpush.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # Check if the correct number of arguments are provided
  3. if [ "$#" -ne 1 ]; then
  4. echo "Usage: $0 <runtimeVersion>"
  5. exit 1
  6. fi
  7. # Get the current commit hash and message
  8. commitHash=$(git rev-parse HEAD)
  9. commitMessage=$(git log -1 --pretty=%B)
  10. # Assign arguments to variables
  11. runtimeVersion=$1
  12. serverHost="https://updates-loan.ewaga.com"
  13. uploadKey="accdcdc"
  14. # Generate a timestamp for the output folder
  15. timestamp=$(date -u +%Y%m%d%H%M%S)
  16. outputFolder="../ota-builds/$timestamp"
  17. # Ask the user to confirm the hash, commit message, runtime version, and output folder
  18. echo "Output Folder: $outputFolder"
  19. echo "Runtime Version: $runtimeVersion"
  20. echo "Commit Hash: $commitHash"
  21. echo "Commit Message: $commitMessage"
  22. read -p "Do you want to proceed with these values? (y/n): " confirm
  23. if [ "$confirm" != "y" ]; then
  24. echo "Operation cancelled by the user."
  25. exit 1
  26. fi
  27. rm -rf $outputFolder
  28. mkdir -p $outputFolder
  29. # Run expo export with the specified output folder
  30. pnpm expo export --max-workers 8 --output-dir $outputFolder
  31. # Extract expo config property from app.json and save to expoconfig.json
  32. jq '.expo' app.json > $outputFolder/expoconfig.json
  33. # Zip the output folder
  34. cd $outputFolder
  35. zip -q -r ${timestamp}.zip .
  36. # Upload the zip file to the server
  37. curl -X POST $serverHost/api/upload -F "file=@${timestamp}.zip" -F "runtimeVersion=$runtimeVersion" -F "commitHash=$commitHash" -F "commitMessage=$commitMessage" -F "uploadKey=$uploadKey"
  38. echo ""
  39. echo "Uploaded to $serverHost/api/upload"
  40. cd ..
  41. # Remove the output folder and zip file
  42. rm -rf $outputFolder
  43. echo "Removed $outputFolder"
  44. echo "Done"