Skip to content

Commit

Permalink
Merge pull request #495 from nimblehq/release/3.22.0
Browse files Browse the repository at this point in the history
[Release] 3.22.0
  • Loading branch information
ryan-conway committed Aug 2, 2023
2 parents 70d21ad + c6cc06d commit 6683929
Show file tree
Hide file tree
Showing 53 changed files with 566 additions and 81 deletions.
34 changes: 34 additions & 0 deletions .cicdtemplate/.codemagic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Setup

Setting up the [Codemagic](https://codemagic.io/start/) to the project starts from adding project to
the Codemagic console.
After that, you can follow the instruction below to setup the environment variables and deployment.

# Environment Variables

You can configure the environment variables for Codemagic by accessing the `Environment Variables`
tab under `App Settings`.
For detailed instructions on how to configure these variables, please refer
to [this document](https://docs.codemagic.io/yaml-basic-configuration/configuring-environment-variables/#configuring-environment-variables)
.

# Deploy to Firebase App Distribution (FAD)

1. Set up the Firebase SDK in your app by following
the [Get started guide for Android](https://firebase.google.com/docs/android/setup).
2. Create service account for Codemagic by following
the [Firebase App Distribution with codemagic.yaml](https://docs.codemagic.io/yaml-publishing/firebase-app-distribution/)
at `Authenticating via service account` which is recommended.
3. Update the script on `app_id` and tester `groups` in `codemagic.yaml` file:

```yaml
publishing:
firebase:
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT
android:
app_id: x:xxxxxxxxxxxx:android:xxxxxxxxxxxxxxxxxxxxxx
groups:
- androidTesters
- ...
artifact_type: 'apk' # Replace with 'aab' to only publish the Android app bundle
```
108 changes: 108 additions & 0 deletions .cicdtemplate/.codemagic/codemagic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
definitions:
configure_environment: &configure_environment
# This running machine can be changed depends on the billing plan: https://docs.codemagic.io/knowledge-codemagic/machine-type/
instance_type: mac_mini_m1
max_build_duration: 30
environment:
groups:
- firebase_credentials
cache:
cache_paths:
- $HOME/.gradle/caches
scripts:
- &set_up_google_services_files_from_environment_variables
name: Set up google-services.json files
script: |
mkdir -p app/src/production
echo $GOOGLE_SERVICES_JSON > app/src/production/google-services.json
mkdir -p app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > app/src/staging/google-services.json
- &detekt
name: Run detekt
script: ./gradlew detekt
- &unit_test
name: Run unit tests
script: ./gradlew koverMergedReport
artifacts:
- &artifacts_test_report build/reports/kover/merged/
- &artifacts_staging_apk app/build/outputs/apk/staging/debug/app-staging-debug.apk
- &artifacts_production_apk app/build/outputs/apk/production/debug/app-production-debug.apk
workflows:
unit-test-on-pr:
name: Unit test on PR
<<: *configure_environment
triggering:
events:
# Run when a pull request is opened or updated
- pull_request
branch_patterns:
# Review changes BEFORE they’re merged into any branches
- pattern: '*'
source: false
# Will not run on develop branch as it is already covered by build-and-deploy-template-compose-staging
- pattern: 'develop'
include: false
# Will not run on main branch as it is already covered by build-and-deploy-template-compose-production
- pattern: 'main'
include: false
cancel_previous_builds: true
scripts:
- *set_up_google_services_files_from_environment_variables
- *detekt
- *unit_test
artifacts:
- *artifacts_test_report

build-and-deploy-staging:
name: Build and deploy staging to Firebase App Distribution
<<: *configure_environment
triggering:
events:
- push
branch_patterns:
- pattern: develop
scripts:
- *set_up_google_services_files_from_environment_variables
- *detekt
- *unit_test
- name: Build APK for staging
script: |
./gradlew assembleStagingDebug -PversionCode=$BUILD_NUMBER
artifacts:
- *artifacts_test_report
- *artifacts_staging_apk
publishing:
firebase:
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT_CREDENTIALS
android:
app_id: $FIREBASE_APP_ID_STAGING
groups:
- android-chapter
artifact_type: 'apk'

build-and-deploy-production:
name: Build and deploy production to Firebase App Distribution
<<: *configure_environment
triggering:
events:
- push
branch_patterns:
- pattern: main
scripts:
- *set_up_google_services_files_from_environment_variables
- *detekt
- *unit_test
- name: Build APK for production
script: |
./gradlew assembleProductionDebug -PversionCode=$BUILD_NUMBER
artifacts:
- *artifacts_test_report
- *artifacts_production_apk
publishing:
firebase:
firebase_service_account: $FIREBASE_SERVICE_ACCOUNT_CREDENTIALS
android:
app_id: $FIREBASE_APP_ID_PRODUCTION
groups:
- android-chapter
artifact_type: 'apk'
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up google-services.json files
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
GOOGLE_SERVICES_JSON_STAGING: ${{ secrets.GOOGLE_SERVICES_JSON_STAGING }}
run: |
mkdir -p app/src/production
echo $GOOGLE_SERVICES_JSON > app/src/production/google-services.json
mkdir -p app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > app/src/staging/google-services.json
- name: Run Detekt
run: ./gradlew detekt

Expand Down
10 changes: 10 additions & 0 deletions .cicdtemplate/.github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
GOOGLE_SERVICES_JSON_STAGING: ${{ secrets.GOOGLE_SERVICES_JSON_STAGING }}
run: |
mkdir -p app/src/production
echo $GOOGLE_SERVICES_JSON > app/src/production/google-services.json
mkdir -p app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > app/src/staging/google-services.json
- name: Run Detekt
run: ./gradlew detekt

Expand Down
7 changes: 7 additions & 0 deletions .cicdtemplate/.github/workflows/run_detekt_and_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up google-services.json
env:
GOOGLE_SERVICES_JSON_STAGING: ${{ secrets.GOOGLE_SERVICES_JSON_STAGING }}
run: |
mkdir -p app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > app/src/staging/google-services.json
- name: Run Detekt
run: ./gradlew detekt

Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
name: Review pull request
runs-on: ubuntu-latest
timeout-minutes: 30
environment: template-compose
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
Expand Down Expand Up @@ -46,6 +47,16 @@ jobs:

# template-compose

- name: Set up google-services.json on template-compose
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
GOOGLE_SERVICES_JSON_STAGING: ${{ secrets.GOOGLE_SERVICES_JSON_STAGING }}
run: |
mkdir -p template-compose/app/src/production
echo $GOOGLE_SERVICES_JSON > template-compose/app/src/production/google-services.json
mkdir -p template-compose/app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > template-compose/app/src/staging/google-services.json
- name: Run Detekt on template-compose
working-directory: ./template-compose
run: ./gradlew detekt
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/run_detekt_and_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
name: Run Detekt and unit tests
runs-on: ubuntu-latest
timeout-minutes: 30
environment: template-compose
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
Expand Down Expand Up @@ -52,6 +53,13 @@ jobs:

# template-compose

- name: Set up google-services.json on template-compose
env:
GOOGLE_SERVICES_JSON_STAGING: ${{ secrets.GOOGLE_SERVICES_JSON_STAGING }}
run: |
mkdir -p template-compose/app/src/staging
echo $GOOGLE_SERVICES_JSON_STAGING > template-compose/app/src/staging/google-services.json
- name: Run Detekt on template-compose
working-directory: ./template-compose
run: ./gradlew detekt
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
---

A collection of our Android templates:

- XML template: **[template-xml](https://github.com/nimblehq/android-templates/tree/develop/template-xml)**
- Compose template: **[template-compose](https://github.com/nimblehq/android-templates/tree/develop/template-compose)**

Expand All @@ -23,6 +24,7 @@ A collection of our Android templates:
1. Clone or download this repository to your local machine, then extract and open the folder
2. Run `cd scripts` to get into the scripts directory
3. Run `kscript new_project.kts` to create a new project with the following arguments:

```
package-name= New package name (i.e., com.example.package)
app-name= New app name (i.e., MyApp, "My App", "my-app")
Expand All @@ -31,10 +33,19 @@ A collection of our Android templates:
destination= Set the output location where the project should be generated (i.e., /Users/johndoe/documents/projectfolder)
```

Examples:
`kscript new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml`
`kscript scripts/new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml`
`kscript new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml destination=/Users/johndoe/documents/projectfolder`
Examples:

```
kscript new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml
```

```
kscript scripts/new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml
```

```
kscript new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml destination=/Users/johndoe/documents/projectfolder
```

4. Update `android_version_code` and `android_version_name` in `template/build.gradle`

Expand All @@ -49,6 +60,7 @@ This project is Copyright (c) 2014 and onwards Nimble. It is free software and m
[LICENSE]: /LICENSE

## About

<a href="https://nimblehq.co/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://assets.nimblehq.co/logo/dark/logo-dark-text-160.png">
Expand Down
2 changes: 1 addition & 1 deletion RxJavaTemplate[DEPRECATED]/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ plugins {
allprojects {
repositories {
google()
maven(url = "https://jitpack.io")
mavenCentral()
maven { url = uri("https://www.jitpack.io") }
}
}

Expand Down
Loading

0 comments on commit 6683929

Please sign in to comment.