-
Notifications
You must be signed in to change notification settings - Fork 20
126 lines (107 loc) · 4.32 KB
/
release_modal_android.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Android Modal (production) deploy
on:
workflow_dispatch:
push:
# branches:
# - 'release_v*'
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
build_with_signing:
name: Build Android App Release
runs-on: macos-latest-xlarge
steps:
# Checkout the repo
- name: Checkout repository
uses: actions/checkout@v4
# Create temp firebase key
- 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'
# 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 and Dependencies
- uses: ./.github/actions/dependencies
with:
working-directory: packages/reown_appkit/example/modal
# Build Android example app
- name: Build Android APK
working-directory: packages/reown_appkit/example/modal
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
APPKIT_AUTH: ${{ secrets.APPKIT_AUTH }}
APPKIT_PROJECT_ID: ${{ secrets.APPKIT_PROJECT_ID }}
AUTH_SERVICE_URL: ${{ secrets.AUTH_SERVICE_URL }}
run: |
# Get app version from file
# VERSION_FILE=$GITHUB_WORKSPACE/lib/version.dart
# VERSION=`echo $(cat $VERSION_FILE) | sed "s/[^']*'\([^']*\)'.*/\1/"`
VERSION=4.0.0
GRADLE_FILE=android/gradle.properties
# 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" --dart-define="APPKIT_AUTH=$APPKIT_AUTH" --dart-define="APPKIT_PROJECT_ID=$APPKIT_PROJECT_ID" --dart-define="AUTH_SERVICE_URL=$AUTH_SERVICE_URL" --release --flavor stable
# 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 }}
# Upload APK
- name: Upload APK
working-directory: packages/reown_appkit/example/modal/build/app/outputs/flutter-apk
env:
APP_ID: ${{ secrets.ANDROID_APP_ID }}
run: |
firebase appdistribution:distribute app-stable-release.apk --app $APP_ID --release-notes "AppKit Flutter sample production" --groups "flutter-team, javascript-team, kotlin-team"
# Notify Channel
- name: Notify Channel
uses: slackapi/slack-github-action@v1.24.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: 'INCOMING_WEBHOOK'
with:
payload: |-
{
"text":"🤖 AppKit *Modal* Flutter Sample *${{ github.ref_name }}* was just deployed. Test at https://appdistribution.firebase.dev/i/a8efff56e3f0fdb0"
}
# Clean up Flutter envs
- name: Clean up
if: ${{ always() }}
run: |
rm $RUNNER_TEMP/flutter-c7c2c-6df892fe6ddb.json
flutter clean
cd example
flutter clean
# Launch locally
# Needs docker to be running
# act -j build_with_signing --container-architecture linux/amd64 -P macos-latest-xlarge=-self-hosted --secret-file .github/workflows/.env.secret.modal -W .github/workflows/release_modal_android.yml