Skip to content

Commit 33bd7a0

Browse files
committed
build android app with gh actions, but dont publish
1 parent 50eb38d commit 33bd7a0

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

.github/workflows/android.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build source code on Android
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build_android:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 24
20+
cache: npm
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Cache Gradle
26+
uses: actions/cache@v3
27+
with:
28+
path: |
29+
~/.gradle/caches
30+
~/.gradle/wrapper
31+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
32+
restore-keys: |
33+
${{ runner.os }}-gradle-
34+
35+
- name: Build app
36+
run: npm run build
37+
38+
- name: Sync Capacitor
39+
run: npx cap sync
40+
41+
- name: Setup Java
42+
uses: actions/setup-java@v4
43+
with:
44+
distribution: 'zulu'
45+
java-version: '17'
46+
47+
- name: Setup Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: '3.0'
51+
bundler-cache: true
52+
53+
# Commented out - not ready to push to App Store yet
54+
# - name: Run Fastlane
55+
# uses: maierj/[email protected]
56+
# env:
57+
# PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }}
58+
# ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE_FILE }}
59+
# DEVELOPER_PACKAGE_NAME: ${{ secrets.DEVELOPER_PACKAGE_NAME }}
60+
# KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
61+
# KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
62+
# KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
63+
# with:
64+
# lane: android beta
65+
66+
- name: Upload artifact
67+
uses: actions/upload-artifact@v2
68+
with:
69+
name: android-release
70+
path: ./android/app/build/outputs/bundle/release/app-release.aab
71+
retention-days: 10

fastlane/Fastfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,61 @@ platform :ios do
137137
# )
138138
# end
139139
end
140+
141+
KEYSTORE_KEY_ALIAS = ENV["KEYSTORE_KEY_ALIAS"]
142+
KEYSTORE_KEY_PASSWORD = ENV["KEYSTORE_KEY_PASSWORD"]
143+
KEYSTORE_STORE_PASSWORD = ENV["KEYSTORE_STORE_PASSWORD"]
144+
145+
platform :android do
146+
desc "Deploy a beta version to the Google Play"
147+
148+
private_lane :verify_changelog_exists do |version_code:|
149+
changelog_path = "android/metadata/en-US/changelogs/#{version_code}.txt"
150+
UI.user_error!("Missing changelog file at #{changelog_path}") unless File.exist?(changelog_path)
151+
UI.message("Changelog exists for version code #{version_code}")
152+
end
153+
154+
private_lane :verify_upload_to_staging do |version_name:|
155+
UI.message "Skipping staging verification step"
156+
end
157+
158+
lane :beta do
159+
keystore_path = "#{Dir.tmpdir}/build_keystore.keystore"
160+
File.write(keystore_path, Base64.decode64(ENV['ANDROID_KEYSTORE_FILE']))
161+
json_key_data = Base64.decode64(ENV['PLAY_CONFIG_JSON'])
162+
163+
# Get previous build number and increment
164+
previous_build_number = google_play_track_version_codes(
165+
package_name: ENV['DEVELOPER_PACKAGE_NAME'],
166+
track: "internal",
167+
json_key_data: json_key_data,
168+
)[0]
169+
current_build_number = previous_build_number + 1
170+
sh("export NEW_BUILD_NUMBER=#{current_build_number}")
171+
172+
# Build the app
173+
gradle(
174+
task: "clean bundleRelease",
175+
project_dir: 'android/',
176+
print_command: false,
177+
properties: {
178+
"android.injected.signing.store.file" => "#{keystore_path}",
179+
"android.injected.signing.store.password" => "#{KEYSTORE_STORE_PASSWORD}",
180+
"android.injected.signing.key.alias" => "#{KEYSTORE_KEY_ALIAS}",
181+
"android.injected.signing.key.password" => "#{KEYSTORE_KEY_PASSWORD}",
182+
'versionCode' => current_build_number
183+
})
184+
185+
# Upload to Play Store
186+
# upload_to_play_store(
187+
# package_name: ENV['DEVELOPER_PACKAGE_NAME'],
188+
# json_key_data: json_key_data,
189+
# track: 'internal',
190+
# release_status: 'completed',
191+
# skip_upload_metadata: true,
192+
# skip_upload_changelogs: true,
193+
# skip_upload_images: true,
194+
# skip_upload_screenshots: true,
195+
# )
196+
end
197+
end

0 commit comments

Comments
 (0)