Skip to content

Commit 9c8cbca

Browse files
Merge pull request #36 from futuredapp/feature/android
Create Android workflows & refactor iOS KMP workflows
2 parents 8dd1218 + ef9bdb2 commit 9c8cbca

8 files changed

+481
-114
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Android Pull Request Check
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
## Required Inputs
7+
LINT_GRADLE_TASKS:
8+
description: "A Gradle task(s) for executing lint check, for example `lintCheck lintRelease`"
9+
required: true
10+
type: string
11+
TEST_GRADLE_TASKS:
12+
description: "A Gradle task(s) for executing unit tests, for example `testReleaseUnitTest` or `testDevEnterpriseUnitTest`"
13+
required: true
14+
type: string
15+
16+
## Optional Inputs
17+
TIMEOUT_MINUTES:
18+
description: "Job timeout in minutes"
19+
required: false
20+
type: number
21+
default: 30
22+
JAVA_VERSION:
23+
description: "Java version to use"
24+
required: false
25+
type: string
26+
default: '17'
27+
JAVA_DISTRIBUTION:
28+
description: "Java distribution to use"
29+
required: false
30+
type: string
31+
default: 'zulu'
32+
33+
jobs:
34+
test:
35+
name: Lint & Tests
36+
runs-on: ubuntu-latest
37+
timeout-minutes: ${{ inputs.TIMEOUT_MINUTES }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
- name: Setup Ruby
42+
uses: ruby/setup-ruby@v1
43+
with:
44+
ruby-version: '3.0'
45+
- name: Setup Java
46+
uses: actions/setup-java@v4
47+
with:
48+
java-version: ${{ inputs.JAVA_VERSION }}
49+
distribution: ${{ inputs.JAVA_DISTRIBUTION }}
50+
- name: Setup Gradle
51+
uses: gradle/actions/setup-gradle@v4
52+
- name: Run Lint Check
53+
shell: bash
54+
run: ./gradlew --continue ${{ inputs.LINT_GRADLE_TASKS }}
55+
- name: Run Unit Tests
56+
shell: bash
57+
run: ./gradlew --continue ${{ inputs.TEST_GRADLE_TASKS }}
58+
- name: Danger action
59+
uses: MeilCli/danger-action@v2
60+
continue-on-error: true
61+
with:
62+
plugins_file: 'Gemfile'
63+
danger_file: 'Dangerfile'
64+
danger_id: 'danger-pr'
65+
env:
66+
# The secrets.GITHUB_TOKEN is implicitly provided by trigger workflow
67+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Android Release to Firebase App Distribution
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
## Required Inputs
7+
TEST_GRADLE_TASKS:
8+
description: "A Gradle task(s) for executing unit tests, for example `testReleaseUnitTest` or `testDevEnterpriseUnitTest`"
9+
required: true
10+
type: string
11+
BUNDLE_GRADLE_TASK:
12+
description: "A Gradle task for assembling app bundle, for example `bundleEnterprise`"
13+
required: true
14+
type: string
15+
UPLOAD_GRADLE_TASK:
16+
description: "A Gradle task for uploading APK, for example `appDistributionUploadEnterprise`"
17+
required: true
18+
type: string
19+
SIGNING_KEYSTORE_PATH:
20+
description: "Path to keystore for signing of universal APK. Example: `keystore/debug.jks' or 'androidApp/signing/debug.keystore'."
21+
required: true
22+
type: string
23+
APP_DISTRIBUTION_GROUPS:
24+
description: "Comma-separated list of app distribution group IDs"
25+
required: true
26+
type: string
27+
28+
## Optional Inputs
29+
VERSION_NAME:
30+
description: "Version name. Example: '1.X.X-snapshot'"
31+
required: false
32+
type: string
33+
default: '1.X.X-snapshot'
34+
BUILD_NUMBER_OFFSET:
35+
description: "Build number offset. This number will be added to GITHUB_RUN_NUMBER and can be used to make corrections to build numbers."
36+
required: false
37+
type: number
38+
default: 0
39+
KMP_FLAVOR:
40+
description: "KMP Build flavor. This is optional and only required by KMP projects and can be ignored on pure Android projects"
41+
required: false
42+
type: string
43+
default: 'test'
44+
SECRET_PROPERTIES_FILE:
45+
description: "A path to file that fill be populated with contents of 'SECRET_PROPERTIES' secret. This file can be picked up by Secrets Gradle plugin to embed secrets into BuildConfig."
46+
required: false
47+
type: string
48+
default: secrets.properties
49+
TIMEOUT_MINUTES:
50+
description: "Job timeout in minutes"
51+
required: false
52+
type: number
53+
default: 30
54+
JAVA_VERSION:
55+
description: "Java version to use"
56+
required: false
57+
type: string
58+
default: '17'
59+
JAVA_DISTRIBUTION:
60+
description: "Java distribution to use"
61+
required: false
62+
type: string
63+
default: 'zulu'
64+
65+
secrets:
66+
SIGNING_KEYSTORE_PASSWORD:
67+
description: "Password to provided keystore"
68+
required: true
69+
SIGNING_KEY_ALIAS:
70+
description: "Alias of the signing key in the provided keystore"
71+
required: true
72+
SIGNING_KEY_PASSWORD:
73+
description: "Password to the key in the provided keystore"
74+
required: true
75+
APP_DISTRIBUTION_SERVICE_ACCOUNT:
76+
required: true
77+
description: "JSON key of service account with permissions to upload build to Firebase App Distribution"
78+
SECRET_PROPERTIES:
79+
required: false
80+
description: "Custom string that contains key-value properties as secrets. Contents of this secret will be placed into file specified by 'SECRET_PROPERTIES_FILE' input."
81+
82+
jobs:
83+
build:
84+
name: Enterprise Build
85+
runs-on: [ ubuntu-latest ]
86+
timeout-minutes: ${{ inputs.TIMEOUT_MINUTES }}
87+
env:
88+
FIREBASE_CREDENTIALS_FILE: firebase_credentials.json
89+
BUNDLETOOL_URL: https://github.com/google/bundletool/releases/download/1.17.2/bundletool-all-1.17.2.jar
90+
EXCLUDE_AAB_FILTER: .*intermediate
91+
steps:
92+
- name: Checkout
93+
uses: actions/checkout@v4
94+
- name: Setup Java
95+
uses: actions/setup-java@v4
96+
with:
97+
java-version: ${{ inputs.JAVA_VERSION }}
98+
distribution: ${{ inputs.JAVA_DISTRIBUTION }}
99+
- name: Setup Gradle
100+
uses: gradle/actions/setup-gradle@v4
101+
- name: Prepare Environment
102+
run: |
103+
{
104+
echo "ANDROID_BUILD_NUMBER=$((GITHUB_RUN_NUMBER + ${{ inputs.BUILD_NUMBER_OFFSET}} ))";
105+
echo "ANDROID_VERSION_NAME=${{ inputs.VERSION_NAME }}";
106+
echo "KMP_FLAVOR=${{ inputs.KMP_FLAVOR }}"
107+
} >> "$GITHUB_ENV"
108+
109+
echo '${{ secrets.SECRET_PROPERTIES }}' > ${{ inputs.SECRET_PROPERTIES_FILE }}
110+
echo '${{ secrets.APP_DISTRIBUTION_SERVICE_ACCOUNT }}' > "$FIREBASE_CREDENTIALS_FILE"
111+
- name: Run Unit tests
112+
shell: bash
113+
run: ./gradlew --continue ${{ inputs.TEST_GRADLE_TASKS }}
114+
- name: Generate Artifacts (AAB and APK)
115+
id: artifacts
116+
env:
117+
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
118+
ANDROID_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
119+
ANDROID_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
120+
shell: bash
121+
run: |
122+
./gradlew ${{ inputs.BUNDLE_GRADLE_TASK }} -P buildkonfig.flavor="$KMP_FLAVOR"
123+
BUNDLE_FILE=$(find . -name '*.aab' | grep -v '.*intermediate')
124+
125+
wget -O bundletool.jar ${{ env.BUNDLETOOL_URL }}
126+
java -jar bundletool.jar build-apks \
127+
--bundle "$BUNDLE_FILE" \
128+
--output universal.apks \
129+
--mode universal \
130+
--ks ${{ inputs.SIGNING_KEYSTORE_PATH }} \
131+
--ks-pass pass:${{ secrets.SIGNING_KEYSTORE_PASSWORD }} \
132+
--ks-key-alias ${{ secrets.SIGNING_KEY_ALIAS }} \
133+
--key-pass pass:${{ secrets.SIGNING_KEY_PASSWORD }}
134+
unzip universal.apks -d universal_apk
135+
UNIVERSAL_APK_FILE=$(find universal_apk/ -name '*.apk')
136+
137+
echo "bundle_file=$BUNDLE_FILE" >> "$GITHUB_OUTPUT"
138+
echo "universal_apk_file=$UNIVERSAL_APK_FILE" >> "$GITHUB_OUTPUT"
139+
- name: Upload to Firebase App Distribution
140+
shell: bash
141+
run: |
142+
./gradlew ${{ inputs.UPLOAD_GRADLE_TASK }} \
143+
--serviceCredentialsFile="$FIREBASE_CREDENTIALS_FILE" \
144+
--groups="${{ inputs.APP_DISTRIBUTION_GROUPS }}" \
145+
--artifactType="APK" \
146+
--artifactPath="${{ steps.artifacts.outputs.universal_apk_file }}"
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Android Release to Google Play
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
## Required Inputs
7+
VERSION_NAME:
8+
description: "Build version name"
9+
required: true
10+
type: string
11+
BUNDLE_GRADLE_TASK:
12+
description: "A Gradle task for assembling app bundle, for example `bundleRelease`"
13+
required: true
14+
type: string
15+
SIGNING_KEYSTORE_PATH:
16+
description: "Path to keystore for signing of universal APK. Example: `keystore/debug.jks' or 'androidApp/signing/debug.keystore'"
17+
required: true
18+
type: string
19+
GOOGLE_PLAY_APPLICATION_ID:
20+
description: "Google Play applicationId"
21+
required: true
22+
type: string
23+
GOOGLE_PLAY_WHATSNEW_DIRECTORY:
24+
description: "Path to directory with changelog files according to documentation in https://github.com/r0adkll/upload-google-play"
25+
required: true
26+
type: string
27+
28+
## Optional Inputs
29+
BUILD_NUMBER_OFFSET:
30+
description: "Build number offset. This number will be added to GITHUB_RUN_NUMBER and can be used to make corrections to build numbers."
31+
required: false
32+
type: number
33+
default: 0
34+
KMP_FLAVOR:
35+
description: "KMP Build flavor. This is optional and only required by KMP projects and can be ignored on pure Android projects"
36+
required: false
37+
type: string
38+
default: 'prod'
39+
SECRET_PROPERTIES_FILE:
40+
description: "A path to file that fill be populated with contents of 'SECRET_PROPERTIES' secret. This file can be picked up by Secrets Gradle plugin to embed secrets into BuildConfig."
41+
required: false
42+
type: string
43+
default: secrets.properties
44+
CHANGES_NOT_SENT_FOR_REVIEW:
45+
description: 'A changesNotSentForReview Google Play flag. Enable when last google review failed, disable when last review was successful.'
46+
type: boolean
47+
required: false
48+
default: false
49+
TIMEOUT_MINUTES:
50+
description: "Job timeout in minutes"
51+
required: false
52+
type: number
53+
default: 30
54+
JAVA_VERSION:
55+
description: "Java version to use"
56+
required: false
57+
type: string
58+
default: '17'
59+
JAVA_DISTRIBUTION:
60+
description: "Java distribution to use"
61+
required: false
62+
type: string
63+
default: 'zulu'
64+
65+
secrets:
66+
SIGNING_KEYSTORE_PASSWORD:
67+
description: "Password to provided keystore"
68+
required: true
69+
SIGNING_KEY_ALIAS:
70+
description: "Alias of the signing key in the provided keystore"
71+
required: true
72+
SIGNING_KEY_PASSWORD:
73+
description: "Password to the key in the provided keystore"
74+
required: true
75+
GOOGLE_PLAY_PUBLISH_SERVICE_ACCOUNT:
76+
required: true
77+
description: "JSON key of service account with permissions to upload build to Google Play"
78+
SECRET_PROPERTIES:
79+
required: false
80+
description: "Custom string that contains key-value properties as secrets. Contents of this secret will be placed into file specified by 'SECRET_PROPERTIES_FILE' input."
81+
82+
jobs:
83+
build:
84+
name: Release Build
85+
runs-on: [ ubuntu-latest ]
86+
timeout-minutes: ${{ inputs.TIMEOUT_MINUTES }}
87+
env:
88+
EXCLUDE_AAB_FILTER: .*intermediate
89+
steps:
90+
- name: Checkout
91+
uses: actions/checkout@v4
92+
- name: Setup Java
93+
uses: actions/setup-java@v4
94+
with:
95+
java-version: ${{ inputs.JAVA_VERSION }}
96+
distribution: ${{ inputs.JAVA_DISTRIBUTION }}
97+
- name: Setup Gradle
98+
uses: gradle/actions/setup-gradle@v4
99+
- name: Prepare Environment
100+
run: |
101+
{
102+
echo "ANDROID_BUILD_NUMBER=$((GITHUB_RUN_NUMBER + ${{ inputs.BUILD_NUMBER_OFFSET}} ))";
103+
echo "ANDROID_VERSION_NAME=${{ inputs.VERSION_NAME }}";
104+
echo "KMP_FLAVOR=${{ inputs.KMP_FLAVOR }}"
105+
} >> "$GITHUB_ENV"
106+
107+
echo '${{ secrets.SECRET_PROPERTIES }}' > ${{ inputs.SECRET_PROPERTIES_FILE }}
108+
- name: Generate Artifacts (AAB)
109+
id: artifacts
110+
env:
111+
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
112+
ANDROID_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
113+
ANDROID_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
114+
shell: bash
115+
run: |
116+
./gradlew ${{ inputs.BUNDLE_GRADLE_TASK }} -P buildkonfig.flavor="$KMP_FLAVOR"
117+
BUNDLE_FILE=$(find . -name '*.aab' | grep -v '.*intermediate')
118+
MAPPING_FILE=$(find . -name mapping.txt)
119+
120+
echo "bundle_file=$BUNDLE_FILE" >> "$GITHUB_OUTPUT"
121+
echo "mapping_file=$MAPPING_FILE" >> "$GITHUB_OUTPUT"
122+
- name: Upload to Google Play
123+
uses: r0adkll/[email protected]
124+
with:
125+
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_PUBLISH_SERVICE_ACCOUNT }}
126+
packageName: ${{ inputs.GOOGLE_PLAY_APPLICATION_ID }}
127+
releaseFiles: ${{ steps.artifacts.outputs.bundle_file }}
128+
track: internal
129+
status: draft
130+
whatsNewDirectory: ${{ inputs.GOOGLE_PLAY_WHATSNEW_DIRECTORY }}
131+
mappingFile: ${{ steps.artifacts.outputs.mapping_file }}
132+
changesNotSentForReview: ${{ toJSON(inputs.CHANGES_NOT_SENT_FOR_REVIEW) }}

0 commit comments

Comments
 (0)