Skip to content

Commit

Permalink
feat: Finishing Android section and changing app name to unused "org.…
Browse files Browse the repository at this point in the history
…dwyl.app". #342
  • Loading branch information
LuchoTurtle committed Oct 24, 2023
1 parent b98ffa5 commit 11f4552
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ jobs:
run: |
flutter build appbundle \
--obfuscate \
--split-debug-info=${{ github.workspace }}/debug_info
--split-debug-info=${{ github.workspace }}/build/app/outputs/symbols
- name: 🚀 Upload Android Release to Play Store
uses: r0adkll/[email protected]
with:
# MUST match the package name defined in `android/app/build.gradle`
packageName: com.dwyl.app
packageName: org.dwyl.app

# Can be 'alpha'/'beta'/'internal'/'production'.
# 'production' is relevant to the final stable version released to ALL clients
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.dwyl.app"
applicationId "org.dwyl.app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.

Expand Down
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dwyl.app">
package="org.dwyl.app">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dwyl.app">
package="org.dwyl.app">
<application
android:label="app"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dwyl.app
package org.dwyl.app

import io.flutter.embedding.android.FlutterActivity

Expand Down
2 changes: 1 addition & 1 deletion android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dwyl.app">
package="org.dwyl.app">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
223 changes: 216 additions & 7 deletions deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,11 @@ Let's go through them right now.
>
> When you create an app, it is permanent.
> Although you can [ask Google to delete it](https://stackoverflow.com/questions/14850708/delete-an-unpublished-app-from-google-play),
> it will only work if it doesn't have any installs.
> according to the following conditions:
> - App must be in good standing (not rejected, removed, or suspended).
> - App must have 0 lifetime installs.
> - App must not be in review.
> - App must be unpublished for 24 hours.
>
> You can *unpublish* an application, but the package name is tied to it *forever*.
> Check https://stackoverflow.com/questions/34846872/how-to-unpublish-an-app-in-google-play-developer-console.
Expand Down Expand Up @@ -957,23 +961,228 @@ In this workflow, we will want to
**mainly create the app bundle and ship it to our published app**
on `Google Play Console`.
We'll create a new workflow
inside `.github/workflows`
and name it `deploy_android.yml`.
Because we're only interested in
deploying features merged into the `main` branch,
this workflow will solely be dedicated to it.
However,
as we've stated before,
you may
you should consider having different workflows
for different environments
that bundle and *release* the app
to different tracks,
be it production, open testing or internal testing.
We'll create a new workflow
inside `.github/workflows`
and name it `deploy_android.yml`.
```yaml
name: Deploy Android (Google Play Store)
on:
# Only trigger, when the "build" workflow succeeded (only works in the Master Branch)
workflow_run:
workflows: ["Build & Test"]
types:
- completed
# Only trigger, when pushing into the `main` branch
push:
branches: [main]
permissions:
contents: write
jobs:
build-and-deploy_android:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout code
uses: actions/checkout@v3
# Needed to base64 decode the upload keystore
- name: ⚙️ Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: "12.x"
cache: 'gradle'
id: java
# Needed to run Flutter-based commands
- name: 🐦 Install Flutter
uses: subosito/flutter-action@v2
with:
# If the flutter version that is used in development increases, it's recommended this one increases as well
flutter-version: "3.13.5"
channel: "stable"
- name: 📚 Install dependencies
run: flutter pub get
- name: 🔒 Retrieve base64 keystore and decode it to a file
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_FILE_BASE64 }}
run: echo $KEYSTORE_BASE64 | base64 --decode > "${{ github.workspace }}/decoded_android-keystore.jks"
# Creates keystore file.
# Needs to be the same as the one defined in `android/app/build.gradle`
- name: 📝🔐 Create key.properties file
env:
KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/android/key.properties
run: |
touch $KEYSTORE_PROPERTIES_PATH
echo 'storeFile=${{ github.workspace }}/decoded_android-keystore.jks' > $KEYSTORE_PROPERTIES_PATH
echo 'keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'storePassword=${{ secrets.KEYSTORE_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH
- name: 📦 Create Android appbundle release
run: |
flutter build appbundle \
--obfuscate \
--split-debug-info=${{ github.workspace }}/debug_info
- name: 🚀 Upload Android Release to Play Store
uses: r0adkll/[email protected]
with:
# MUST match the package name defined in `android/app/build.gradle`
packageName: org.dwyl.app
# Can be 'alpha'/'beta'/'internal'/'production'.
# 'production' is relevant to the final stable version released to ALL clients
# 'internal' can be used for development versions and testing
# 'alpha' and 'beta' can be used for pre-release/staging purposes, with a smaller userbase
track: production
releaseFiles: ${{ github.workspace }}/build/app/outputs/bundle/release/app-release.aab
serviceAccountJsonPlainText: "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON }}"
```
That's a lot!
We'll go over each step and explain it.
- in the `on` section,
we are only triggering the workflow
**when changes are pushed into the `main` branch**
and only after the `build` workflow succeeds.
- we need to define the `permissions > contents`
to `write` because we'll need to correctly
create the local upload keystore
and to create the app bundle.
- next, we define the `build-and-deploy_android` job.
We are running it on a `ubuntu` environment.
Firstly, we check out the code and install the needed dependencies.
We are installing `Java`
(so we can decode the base64-encoded keystore
we have in our repo secrets),,
installing `Flutter`
(to create the app bundle)
and the project dependencies
for the same reason.
```yaml
steps:
- name: ⬇️ Checkout code
uses: actions/checkout@v3
# Needed to base64 decode the upload keystore
- name: ⚙️ Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: "12.x"
cache: 'gradle'
id: java
# Needed to run Flutter-based commands
- name: 🐦 Install Flutter
uses: subosito/flutter-action@v2
with:
# If the flutter version that is used in development increases, it's recommended this one increases as well
flutter-version: "3.13.5"
channel: "stable"
- name: 📚 Install dependencies
run: flutter pub get
```
- after, we **decode the base64-encoded keystore in our repository secrets**.
This upload keystore holds the information
to correctly **sign the app bundle**.
We extract the decoded information
and create a copy of this file locally.
Remember, this file is used in the `android/app/build.gradle` file
to bundle and sign the app.
```yaml
- name: 📝🔐 Create key.properties file
env:
KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/android/key.properties
run: |
touch $KEYSTORE_PROPERTIES_PATH
echo 'storeFile=${{ github.workspace }}/decoded_android-keystore.jks' > $KEYSTORE_PROPERTIES_PATH
echo 'keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'storePassword=${{ secrets.KEYSTORE_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH
echo 'keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}' >> $KEYSTORE_PROPERTIES_PATH
```
- next, we create our Android app bundle!
We are obfuscating the code for increased security.
Check [2. Building app for release](#2-building-app-for-release)
for more information.
```yaml
- name: 📦 Create Android appbundle release
run: |
flutter build appbundle \
--obfuscate \
--split-debug-info=${{ github.workspace }}/build/app/outputs/symbols
```
- finally, we upload our newly created app bundle!
For this,
we are going to be using
[`r0adkll/[email protected]`](https://github.com/r0adkll/upload-google-play).
We need to set up the **package name**
(it identifies your application in the app store),
the **track** we're uploading into
(it can be `production`, `internal`, `alpha` or `beta`,
for public release, internal and limited user testing, respectively),
the **path to the app bundle**
and the **service account `json` file**
(which is a repository secret we've defined earlier).
```yaml
- name: 🚀 Upload Android Release to Play Store
uses: r0adkll/[email protected]
with:
# MUST match the package name defined in `android/app/build.gradle`
packageName: org.dwyl.app
# Can be 'alpha'/'beta'/'internal'/'production'.
# 'production' is relevant to the final stable version released to ALL clients
# 'internal' can be used for development versions and testing
# 'alpha' and 'beta' can be used for pre-release/staging purposes, with a smaller userbase
track: production
releaseFiles: ${{ github.workspace }}/build/app/outputs/bundle/release/app-release.aab
serviceAccountJsonPlainText: "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON }}"
```
And that's it!
// TODO add workflow file here.
Congratulations, you've automated the release process
of a `Google Play` app!
Do not forget that versions should be
**correctly incremented**
so new releases are correctly uploaded.
Please visit [A note before releasing a new version](#a-note-before-releasing-a-new-version)
for more information about this.
## 🍏 Apple `App Store`
Expand Down
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.dwyl.app;
PRODUCT_BUNDLE_IDENTIFIER = org.dwyl.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -493,7 +493,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.dwyl.app;
PRODUCT_BUNDLE_IDENTIFIER = org.dwyl.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -515,7 +515,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.dwyl.app;
PRODUCT_BUNDLE_IDENTIFIER = org.dwyl.app;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(runner LANGUAGES CXX)
set(BINARY_NAME "app")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "com.dwyl.app")
set(APPLICATION_ID "org.dwyl.app")

# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
Expand Down
2 changes: 1 addition & 1 deletion macos/Runner/Configs/AppInfo.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PRODUCT_NAME = app

// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = com.dwyl.app
PRODUCT_BUNDLE_IDENTIFIER = org.dwyl.app

// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved.

0 comments on commit 11f4552

Please sign in to comment.