Skip to content

Commit

Permalink
[GitHub Actions] Create Workflow to Deploy Demo App to Google Play (#201
Browse files Browse the repository at this point in the history
)

* Disable debugging on Demo release artifact.

* Update google play store credentials for automated Play Store CI step.

* Update env variable names.

* Update service account credentials block.

* Add GitHub Actions workflow for deploying to Google Play.

* Fix github actions typo.

* Remove unecessary comment.

* Add release notes generated by plugin.

* Remove versionCode and versionName from library modules.

* Remove version code increment from release script.

* Increment demo app version code in GitHub Actions.

* Reset build variable to its current value.
  • Loading branch information
sshropshire authored Oct 24, 2023
1 parent 00809be commit ef8390a
Showing 13 changed files with 105 additions and 22 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/release_demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release Demo
on: workflow_dispatch
env:
DEMO_KEYSTORE_FILE: /home/runner/demo_keystore.keystore
DEMO_GCP_SERVICE_ACCOUNT_CREDENTIALS_FILE: /home/runner/demo_gcp_service_account_credentials.json
jobs:
bump_demo_app_version_code:
name: Bump Demo App Version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set github user
uses: ./.github/actions/set_github_user
- name: Update Version
run: |
VERSION_CODE=$(./gradlew -q getDemoAppVersionCode)
UPDATED_VERSION_CODE=$((${VERSION_CODE} + 1))
./gradlew -PdemoAppVersionCodeParam=${UPDATED_VERSION_CODE} setDemoAppVersionCode
git add .
git commit -m 'Bump demo app version code to ${UPDATED_VERSION_CODE}'
git push origin HEAD
publish_demo_app:
needs: [ bump_demo_app_version_code ]
name: Publish Demo App
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Java 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'microsoft'
- name: Decode Demo Keystore
run: |
echo "${{ secrets.DEMO_KEYSTORE_BASE64_ENCODED }}" > ~/demo_keystore.keystore.b64
base64 -d ~/demo_keystore.keystore.b64 > "${DEMO_KEYSTORE_FILE}"
- name: Decode Demo GCP Service Account Credentials
run: |
echo "${{ secrets.DEMO_GCP_SERVICE_ACCOUNT_CREDENTIALS_BASE64_ENCODED }}" > ~/gcp_service_account_credentials.json.b64
base64 -d ~/gcp_service_account_credentials.json.b64 > "${DEMO_GCP_SERVICE_ACCOUNT_CREDENTIALS_FILE}"
- name: Publish Release Bundle
run: ./gradlew publishReleaseBundle
env:
DEMO_KEYSTORE_PASSWORD: ${{ secrets.DEMO_KEYSTORE_PASSWORD }}
DEMO_KEY_ALIAS: ${{ secrets.DEMO_KEY_ALIAS }}
DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }}
2 changes: 0 additions & 2 deletions CardPayments/build.gradle
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ android {
defaultConfig {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
2 changes: 0 additions & 2 deletions CorePayments/build.gradle
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ android {
defaultConfig {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
buildConfigField "String", "CLIENT_SDK_VERSION", "\"$versionName\""
31 changes: 28 additions & 3 deletions Demo/build.gradle
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ plugins {
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
id 'com.github.triplet.play' version '3.8.4'
}

def paypalProperties = loadPropertiesFromFile("paypal.properties")
@@ -16,12 +17,11 @@ android {
applicationId "com.paypal.android"
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
versionCode modules.demoAppVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "CLIENT_ID", paypalProperties["CLIENT_ID"] ?: "\"\"")
signingConfig signingConfigs.debug
}

buildFeatures {
@@ -61,6 +61,31 @@ android {
java.srcDirs += "src/androidTestShared/java"
}
}

// https://developer.android.com/build/build-variants#groovy
signingConfigs {
release {
storeFile file(System.getenv('DEMO_KEYSTORE_FILE') ?: 'debug.keystore')
storePassword System.getenv('DEMO_KEYSTORE_PASSWORD') ?: 'android'
keyAlias System.getenv('DEMO_KEY_ALIAS') ?: 'androiddebugkey'
keyPassword System.getenv('DEMO_KEY_PASSWORD') ?: 'android'
}
}
buildTypes {
release {
debuggable false
signingConfig signingConfigs.release
}
debug {
debuggable true
}
}
}

play {
// Ref: https://github.com/Triple-T/gradle-play-publisher/issues/979#issuecomment-884763388
releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.DRAFT)
serviceAccountCredentials.set(file(System.getenv("DEMO_GCP_SERVICE_ACCOUNT_CREDENTIALS_FILE") ?: '/path/to/credential_file.json'))
}

// Ref: https://developer.android.com/training/dependency-injection/hilt-android#setup
1 change: 1 addition & 0 deletions Demo/src/main/play/default-language.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
en-US
1 change: 1 addition & 0 deletions Demo/src/main/play/listings/en-US/title.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PayPal SDK
1 change: 1 addition & 0 deletions Demo/src/main/play/release-notes/en-US/internal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test Release
2 changes: 0 additions & 2 deletions FraudProtection/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ android {
defaultConfig {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
2 changes: 0 additions & 2 deletions PayPalNativePayments/build.gradle
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ android {
//minSdkVersion 21
minSdkVersion 23
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
2 changes: 0 additions & 2 deletions PayPalWebPayments/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ android {
defaultConfig {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
2 changes: 0 additions & 2 deletions PaymentButtons/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ android {
defaultConfig {
minSdkVersion modules.androidMinSdkVersion
targetSdkVersion modules.androidTargetVersion
versionCode modules.sdkVersionCode
versionName modules.sdkVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
2 changes: 0 additions & 2 deletions Venmo/build.gradle
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ android {
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName modules.sdkVersionName

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
29 changes: 24 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ buildscript {

ext.modules = [
"sdkVersionName" : "1.0.1-SNAPSHOT",
"sdkVersionCode" : 18,
"demoAppVersionCode" : 2,
"androidMinSdkVersion": 21,
"androidTargetVersion": 30
]
@@ -215,10 +215,29 @@ task changeReleaseVersion {
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def updatedScript =
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + '",')
def matcher = updatedScript =~ /"sdkVersionCode"\s*: ([0-9]*),/
def versionCode = matcher[0][1].toInteger() + 1
def finalScript = updatedScript.replaceFirst(/("sdkVersionCode"\s*: )[0-9]*,/, '$1' + versionCode + ',')
topLevelGradleFile.write(finalScript, 'UTF-8')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}

task getDemoAppVersionCode {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')

def matcher = topLevelGradleFileText =~ /"demoAppVersionCode"\s*: ([0-9]*),/
def versionCode = matcher[0][1].toInteger()
println(versionCode)
}
}

//./gradlew -PdemoAppVersionCodeParam=0.0.1 changeReleaseVersion
task setDemoAppVersionCode {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def updatedScript =
topLevelGradleFileText.replaceFirst(/("demoAppVersionCode"\s*: )[0-9]*,/, '$1' + demoAppVersionCodeParam + ',')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}

0 comments on commit ef8390a

Please sign in to comment.