Build Android App Internal (beta) #1
This file contains 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
name: Build Android App Internal (beta) | |
on: | |
workflow_dispatch: | |
push: | |
# branches: | |
# - master | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+(-beta)+[0-9]*' | |
jobs: | |
build_with_signing: | |
runs-on: macos-latest | |
steps: | |
# Checkout the repo | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create temp firebase key | |
env: | |
FIREBASE_KEY_BASE64: ${{ secrets.FIREBASE_KEY_BASE64 }} | |
run: | | |
# create variables | |
FIREBASE_KEY_PATH=$RUNNER_TEMP/flutter-c7c2c-6df892fe6ddb.json | |
# import certificate and provisioning profile from secrets | |
echo -n "$FIREBASE_KEY_BASE64" | base64 --decode -o $FIREBASE_KEY_PATH | |
# Setup Java 11 | |
- name: Setup Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
architecture: x86_64 | |
cache: 'gradle' | |
- name: Cache Gradle | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# Install Flutter SDK | |
- name: Install Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
architecture: x64 | |
# Get package dependencies and generate files | |
- name: Get package dependencies and generate files | |
run: | | |
flutter pub get | |
flutter pub run build_runner build --delete-conflicting-outputs | |
# Get example app dependencies and generate files | |
- name: Get example app dependencies and generate files | |
working-directory: example | |
run: | | |
flutter pub get | |
flutter pub run build_runner build --delete-conflicting-outputs | |
# Build Android example app | |
- name: Build Android APK | |
working-directory: example | |
env: | |
PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
run: | | |
# Get app version from file | |
GRADLE_FILE=android/gradle.properties | |
VERSION_FILE=$GITHUB_WORKSPACE/lib/version.dart | |
VERSION=`echo $(cat $VERSION_FILE) | sed "s/[^']*'\([^']*\)'.*/\1/"` | |
# # Change packageName in build.gradle | |
# sed -i '' 's/com.web3modal.flutterExample/com.web3modal.flutterExample.internal/g' android/app/build.gradle | |
# sed -i '' 's/com.web3modal.flutterExample/com.web3modal.flutterExample.internal/g' android/app/src/main/kotlin/com/example/sign/MainActivity.kt | |
# Set versionName on gradle.properties | |
awk -F"=" -v newval="$VERSION" 'BEGIN{OFS=FS} $1=="versionName"{$2=newval}1' $GRADLE_FILE > "$GRADLE_FILE.tmp" && mv "$GRADLE_FILE.tmp" $GRADLE_FILE | |
# Increment versionCode (build number) on gradle.properties | |
awk -F"=" 'BEGIN{OFS=FS} $1=="versionCode"{$2=$2+1}1' $GRADLE_FILE > "$GRADLE_FILE.tmp" && mv "$GRADLE_FILE.tmp" $GRADLE_FILE | |
# Get new versionCode | |
NEXT_BUILD=$(grep 'versionCode' $GRADLE_FILE | cut -d'=' -f2) | |
# Build Android app with flutter | |
flutter build apk --build-name $VERSION --build-number $NEXT_BUILD --dart-define="PROJECT_ID=$PROJECT_ID" --release --flavor beta | |
# Setup Node | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
# Setup Firebase | |
- name: Setup Firebase | |
uses: w9jds/setup-firebase@main | |
with: | |
tools-version: 13.0.1 | |
firebase_token: ${{ secrets.FIREBASE_TOKEN }} | |
- name: Upload APK | |
working-directory: example/build/app/outputs/flutter-apk | |
env: | |
APP_ID: ${{ secrets.ANDROID_APP_ID_INTERNAL }} | |
run: | | |
firebase appdistribution:distribute app-beta-release.apk --app $APP_ID --release-notes "Web3Modal Flutter beta release" --groups "flutter-team, javascript-team, kotlin-team" | |
- name: Notify Channel | |
uses: slackapi/[email protected] | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: 'INCOMING_WEBHOOK' | |
with: | |
payload: |- | |
{ | |
"text":"🤖 New *Android* build *${{ github.ref_name }}* version for *Web3Modal Flutter* was just deployed. Test at https://appdistribution.firebase.dev/i/a47ee97e86fbdfff" | |
} | |
# Clean up Flutter envs | |
- name: Clean up | |
if: ${{ always() }} | |
run: | | |
rm $RUNNER_TEMP/flutter-c7c2c-6df892fe6ddb.json | |
flutter clean | |
cd example | |
flutter clean |