Skip to content

Instantly share code, notes, and snippets.

@nilsreichardt
Created July 29, 2022 17:44
Show Gist options
  • Save nilsreichardt/0521a23df8cac064cf2b103f2e263ff3 to your computer and use it in GitHub Desktop.
Save nilsreichardt/0521a23df8cac064cf2b103f2e263ff3 to your computer and use it in GitHub Desktop.
A script to bump the app version, deploy the app to App Store Connect and Firebase Distribution and create a GitHub release with a changelog.
#!/bin/bash
# Script to deploy a new app update to the alpha environment manually.
#
# This script is not used by CI. It's meant to be run manually to avoid high CI
# build times.
#
# When the compnay has more money, we should only deploy to the alpha track via
# CI and delete this script.
# Requirements:
# - Install Git
# - Sign in to XCode for signing (in most cases you have already done this)
# - Sign configuraitons for Android (`android/key.properties`)
# - Create a new App Store Connect API key
# (`https://appstoreconnect.apple.com/access/api`)
# - Add the private key file to `private_keys/AuthKey_7UG2F7CA56.p8` (your key
# will have a different name, the `privte_keys` directory needs to be on the
# same level as the pubpsec.yaml)
# - Install the cider package (`dart pub global activate cider``)
# - Install Firebase CLI & authenticate (`npm install -g firebase-tools``)
# - Install GitHub CLI & authenticate (`brew install gh`)
TYPE="patch" # "major", "minor", "patch"
APPSTORE_KEY_ID="7UG2F7CA56"
APPSTORE_ISSUER="a8d211c8-960a-4ba8-8084-156c1acedee6"
FIREBASE_ANDROID_APP_ID="1:866458991504:android:d541c9fbeae09e3076d115"
VERSION_WITH_BUILD_NUMBER=$(cider bump $TYPE --bump-build)
VERSION=(${VERSION_WITH_BUILD_NUMBER//+/ })
echo "🚀 Creating release for version $VERSION"
# Build iOS
echo "⚙️ Building iOS"
flutter build ipa --flavor prod -t lib/features/run_config/main_prod.dart
echo "✅ iOS build complete"
echo "⚙️ Building Android"
flutter build apk --flavor prod -t lib/features/run_config/main_prod.dart
echo "✅ Android build complete"
echo "⚙️ Uploading IPA to AppStore"
# When running this command, you might see a bunch off errors like, `*** Error:
# /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool (2):
# bitcode-build-tool internal error`. You can ignore these.
xcrun altool --upload-app --type ios -f build/ios/ipa/*.ipa --apiKey $APPSTORE_KEY_ID --apiIssuer $APPSTORE_ISSUER
echo "✅ Uploaded IPA to AppStore"
echo "⚙️ Uploading APK to Firebase Distribution"
firebase appdistribution:distribute build/app/outputs/flutter-apk/app-prod-release.apk --app $FIREBASE_ANDROID_APP_ID --groups "alpha"
echo "✅ Uploaded APK to Firebase Distribution"
gh release create "v$VERSION" --generate-notes --prerelease
echo "✅ Created GitHub Release for v$VERSION"
git add pubspec.yaml
git commit -m "Bump app version to $($VERSION_WITH_BUILD_NUMBER)"
git push
echo "🎉 Finished deploying v$VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment