Skip to content

Commit

Permalink
access build number then increment
Browse files Browse the repository at this point in the history
  • Loading branch information
bwees committed Aug 28, 2024
1 parent c41edb1 commit 4e295a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ jobs:
KEY_PASSWORD: ${{ secrets.AAB_PASSWORD }}
STORE_PASSWORD: ${{ secrets.AAB_PASSWORD }}
KEY_PATH: ${{ github.workspace }}/android/app/maroon-rides-release-key.jks

GOOGLE_PLAY_KEY: ${{ secrets.GOOGLE_PLAY_KEY }}

- uses: actions/upload-artifact@v4
with:
name: app-bundle.aab
Expand Down
16 changes: 16 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ default_platform(:android)
platform :android do
desc "Build APK with Gradle"
lane :build do

# Fetch the latest version code from the Google Play Store for the 'internal' track
latest_version_code = google_play_track_version_codes(
track: 'internal',
json_key_data: Base64.decode64(ENV['GOOGLE_PLAY_KEY'])
).max || 1

# Increment the version code
new_version_code = latest_version_code + 1
UI.message("New Version Code: #{new_version_code}")

# Update the versionCode in the build.gradle file
gradle_file = "./android/app/build.gradle"
new_gradle_content = File.read(gradle_file).gsub(/versionCode \d+/, "versionCode #{new_version_code}")
File.write(gradle_file, new_gradle_content)

gradle(
task: "bundle",
build_type: "Release",
Expand Down

0 comments on commit 4e295a6

Please sign in to comment.