Skip to content

Commit fd4445f

Browse files
malmsteinaitorvs
authored andcommitted
GHA: Upload AAB to Play Store and Firebase (#5176)
Task/Issue URL: https://app.asana.com/0/42792087274227/1208606985938250/f ### Description This PR enables nightly releases from GHA ### Steps to test this PR Run the workflow
1 parent fdc71e4 commit fd4445f

File tree

4 files changed

+137
-7
lines changed

4 files changed

+137
-7
lines changed

.github/workflows/release_nightly.yml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Release - Nightly Release to Internal and Firebase
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *' # run at 3 AM UTC
6+
workflow_dispatch:
7+
8+
env:
9+
ASANA_PAT: ${{ secrets.GH_ASANA_SECRET }}
10+
GOOGLE_APPLICATION_CREDENTIALS: '#{ENV["HOME"]}/jenkins_static/com.duckduckgo.mobile.android/ddg-upload-firebase.json'
11+
12+
jobs:
13+
create-tag:
14+
name: Generate and upload nightly bundle to Play Store Internal track
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
token: ${{ secrets.GT_DAXMOBILE }}
23+
24+
- name: Set Git permissions
25+
uses: oleksiyrudenko/gha-git-credentials@v2-latest
26+
with:
27+
token: '${{ secrets.GT_DAXMOBILE }}'
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'adopt'
34+
35+
- name: Set up ruby env
36+
uses: ruby/setup-ruby@v1
37+
with:
38+
ruby-version: 2.7.2
39+
bundler-cache: true
40+
41+
- name: Get latest tag
42+
id: get_latest_tag
43+
run: |
44+
git fetch --tags
45+
output=$(git describe --tags `git rev-list --tags --max-count=1`)
46+
echo "Latest tag: $output"
47+
echo "latest_tag=$output" >> $GITHUB_OUTPUT
48+
49+
- name: Decode upload keys
50+
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208
51+
with:
52+
secret: ${{ secrets.UPLOAD_RELEASE_PROPERTIES }}
53+
fileName: ddg_android_build_upload.properties
54+
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/
55+
56+
- name: Decode key file
57+
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208
58+
with:
59+
secret: ${{ secrets.UPLOAD_RELEASE_KEY }}
60+
fileName: ddg-upload-keystore.jks
61+
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/
62+
63+
- name: Decode Play Store credentials file
64+
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208
65+
with:
66+
secret: ${{ secrets.UPLOAD_PLAY_CREDENTIALS }}
67+
fileName: api.json
68+
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/
69+
70+
- name: Decode Firebase credentials file
71+
uses: davidSchuppa/base64Secret-toFile-action@199e78f212c854d2284fada7f3cd3aba3e37d208
72+
with:
73+
secret: ${{ secrets.UPLOAD_FIREBASE_CREDENTIALS }}
74+
fileName: ddg-upload-firebase.json
75+
destination-path: $HOME/jenkins_static/com.duckduckgo.mobile.android/
76+
77+
- name: Clean project
78+
run: |
79+
gradle clean
80+
81+
- name: Assemble the bundle
82+
run: gradle bundleInternalRelease -PversionNameSuffix=-nightly -PuseUploadSigning -PlatestTag=${{ steps.get_latest_tag.outputs.latest_tag }}
83+
84+
- name: Generate nightly version name
85+
id: generate_version_name
86+
run: |
87+
output=$(gradle getBuildVersionName -PversionNameSuffix=-nightly -PlatestTag=${{ steps.get_latest_tag.outputs.latest_tag }} --quiet | tail -n 1)
88+
echo "version=$output" >> $GITHUB_OUTPUT
89+
90+
- name: Capture App Bundle Path
91+
id: capture_output
92+
run: |
93+
output=$(find app/build/outputs/bundle/internalRelease -name "*.aab")
94+
echo "bundle_path=$output" >> $GITHUB_OUTPUT
95+
96+
- name: Upload bundle to Play Store Internal track
97+
id: create_app_bundle
98+
run: |
99+
bundle exec fastlane deploy_dogfood aab_path:${{ steps.capture_output.outputs.bundle_path }}
100+
101+
- name: Tag Nightly release
102+
id: tag_nightly_release
103+
run: |
104+
git tag -a ${{ steps.generate_version_name.outputs.version }} -m "Create tag ${{ steps.generate_version_name.outputs.version }} for nightly release."
105+
git push origin ${{ steps.generate_version_name.outputs.version }}
106+
107+
- name: Upload APK as artifact
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: duckduckgo-${{ steps.generate_version_name.outputs.version }}.apk
111+
path: duckduckgo.apk
112+
113+
- name: Create Asana task when workflow failed
114+
if: ${{ failure() }}
115+
uses: duckduckgo/[email protected]
116+
with:
117+
asana-pat: ${{ secrets.GH_ASANA_SECRET }}
118+
asana-project: ${{ vars.GH_ANDROID_APP_PROJECT_ID }}
119+
asana-section: ${{ vars.GH_ANDROID_APP_INCOMING_SECTION_ID }}
120+
asana-task-name: GH Workflow Failure - Nightly Release
121+
asana-task-description: The Nightly Release Task workflow has failed. See https://github.com/duckduckgo/Android/actions/runs/${{ github.run_id }}
122+
action: 'create-asana-task'

fastlane/Appfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
json_key_file("~/jenkins_static/com.duckduckgo.mobile.android/api.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
2-
package_name("com.duckduckgo.mobile.android") # e.g. com.krausefx.app
2+
package_name("com.duckduckgo.mobile.android") # e.g. com.krausefx.app

fastlane/Fastfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
releaseNotesBodyHeader = "What's new:"
1919
releaseNotesFileBody = "../app/version/release-notes"
2020
appVersionFilePath = "../app/version/version-properties"
21+
firebaseFilePath = "#{ENV["HOME"]}/jenkins_static/com.duckduckgo.mobile.android/ddg-upload-firebase.json"
2122
releaseNotesLocales= ["en-US", "en-GB", "en-CA"]
2223
releaseNotesMaxLength = 500
2324
errorMessageCancelled = "Release cancelled 😢"
@@ -173,6 +174,7 @@ platform :android do
173174
lane :deploy_dogfood do |options|
174175

175176
UI.message("Aab path: #{options[:aab_path]}")
177+
176178
upload_to_play_store(
177179
aab: options[:aab_path],
178180
track: 'internal',
@@ -193,7 +195,8 @@ platform :android do
193195
app: "1:239339218528:android:732e03dcf13d1488db8505",
194196
groups: "ddg-employees",
195197
android_artifact_type: "APK",
196-
android_artifact_path: apkPath
198+
android_artifact_path: apkPath,
199+
service_credentials_file: firebaseFilePath
197200
)
198201

199202
end
@@ -563,7 +566,4 @@ platform :android do
563566
(major * 10_000_000) + (minor * 10_000) + (patch * 1_000)
564567
end
565568

566-
567-
568-
569569
end

versioning.gradle

+10-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,19 @@ ext {
3535
}
3636
}
3737

38+
getStoredTag = {
39+
if(project.hasProperty("latestTag")) {
40+
return project["latestTag"]
41+
} else {
42+
def latestGitTagProvider = providers.of(LatestGitTagValueSource.class) {}
43+
return latestGitTagProvider.get()
44+
}
45+
}
46+
3847
buildNumberCode = {
3948
def suffix = getVersionNameSuffix()
4049
if (suffix?.trim()) {
41-
def latestGitTagProvider = providers.of(LatestGitTagValueSource.class) {}
42-
def tag = latestGitTagProvider.get()
50+
def tag = getStoredTag()
4351
if (tag.contains('nightly')) {
4452
def (major, minor, patch, nightly) = tag.toLowerCase().tokenize('.')
4553
(major, minor, patch, nightly) = [major, minor, patch, nightly].collect { it.toString() }

0 commit comments

Comments
 (0)