Table of Contents
- Introduction
- Requirements
- Setting up Firebase CLI
- Deploy Script: Bash, Zsh, and Fish
- Running the Function
- Adding Notifications After Deployment
- Conclusion
1. Introduction
Deploying APKs to Firebase manually can be time-consuming. To streamline this process, we can use automation scripts to deploy with a single command.
This guide will walk you through setting up Firebase CLI and creating a deployment function using Bash, Zsh, and Fish, along with adding notifications upon completion.
2. Requirements
Before starting, ensure you have:
- Flutter installed and configured (run
flutter doctor
to check). - Firebase CLI installed and linked to your Firebase account.
- Bash, Zsh, or Fish Shell depending on your system.
- A Firebase account with Firebase App Distribution configured for your Flutter project.
- APP_ID, found in Firebase Console.
3. Setting up Firebase CLI
- Log in to Firebase CLI:
firebase login
- Get your Firebase project list:
firebase projects:list
- Retrieve APP_ID from Firebase Console:
- Open Firebase Console.
- Select your project.
- Go to Project settings.
- In the General tab, find Your apps and copy the APP_ID for your Android app.
4. Deploy Script: Bash, Zsh, and Fish
Replace your-app-id
with the APP_ID retrieved from Firebase Console.
function deployPPM() {
APP_ID="your-app-id"
flutter clean
flutter build apk --release && firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk --app $APP_ID --release-notes "$1" --groups Tester1
}
For Fish Shell, use:
function deployPPM
set APP_ID "your-app-id"
flutter clean
flutter build apk --release && firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk --app $APP_ID --release-notes $argv[1] --groups Tester1
end
5. Running the Function
To run the function, use:
deployPPM "Latest version release notes"
6. Adding Notifications After Deployment
For Xubuntu, add a notification:
function deployPPM() {
APP_ID="your-app-id"
flutter clean
flutter build apk --release && firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk --app $APP_ID --release-notes "$1" --groups Tester1 && notify-send "Deployment Complete" "APK successfully uploaded to Firebase."
}
For macOS, replace notify-send
with osascript
:
osascript -e 'display notification "APK successfully uploaded to Firebase." with title "Deployment Complete"'
7. Conclusion
Using Bash, Zsh, or Fish functions, you can automate APK deployment to Firebase App Distribution with a single command. This saves time and reduces manual errors.
To deploy, simply run:
deployPPM "New feature updates and bug fixes."
You’ll receive a notification once the deployment is complete. 🚀