Skip to content

Commit

Permalink
feat: Add internal and production track to release into PlayStore on CD
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentKobz committed Jul 18, 2024
1 parent 1708abc commit 95e6d25
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 25 deletions.
73 changes: 51 additions & 22 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,56 @@ jobs:
distribution: 'zulu'
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
- name: Gradle build
run: ./gradlew build
env:
GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }}
GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }}
- name: Publish the library to MavenCentral
run: ./gradlew publish

- name: Setup Ruby
run: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2
bundler-cache: true

# - name: Gradle build
# run: ./gradlew build
# env:
# GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }}
# GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }}
# - name: Publish the library to MavenCentral
# run: ./gradlew publish
# env:
# OSSRH_LOGIN: ${{ secrets.OSSRH_LOGIN }}
# OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
# SIGN_KEYID: ${{ secrets.SIGN_KEYID }}
# SIGN_KEY: ${{ secrets.SIGN_KEY }}
# SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }}
# LIB_VERSION: ${{ steps.get_version.outputs.VERSION }}
# GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }}
# GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }}
# - name: Rename the AAR file for GitHub release upload
# run: mv enioka_scan/build/outputs/aar/enioka_scan-release.aar enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar
# - name: Create a GitHub release with the AAR file as an asset
# uses: softprops/action-gh-release@v2
# with:
# name: ${{ steps.get_version.outputs.VERSION }}
# files: enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar
# token: ${{ secrets.GITHUB_TOKEN }}

- name: Restore json key
run: echo "${{ secrets.GOOGLE_API_PUB_JSON_BASE64 }}" | base64 --decode > ${{ github.workspace }}/service-account.json

- name: Restore keystore
run: echo "${{ secrets.GOOGLE_KEYSTORE_BASE64 }}" | base64 --decode > ${{ github.workspace }}/demoscannerapp/debug.keystore

- name: Fastlane build and upload
run: bundle exec fastlane internal
env:
OSSRH_LOGIN: ${{ secrets.OSSRH_LOGIN }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGN_KEYID: ${{ secrets.SIGN_KEYID }}
SIGN_KEY: ${{ secrets.SIGN_KEY }}
SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }}
LIB_VERSION: ${{ steps.get_version.outputs.VERSION }}
GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }}
GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }}
- name: Rename the AAR file for GitHub release upload
run: mv enioka_scan/build/outputs/aar/enioka_scan-release.aar enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar
- name: Create a GitHub release with the AAR file as an asset
uses: softprops/action-gh-release@v2
KEYSTORE_PASSWORD: ${{ secrets.GOOGLE_KEYSTORE_PASSWORD }}
SIGNKEY_PASSWORD: ${{ secrets.GOOGLE_SIGNKEY_PASSWORD }}
KEY_ALIAS: ${{ secrets.GOOGLE_SIGNKEY_ALIAS }}

- name: Gradle build
run: ./gradlew demoscannerapp:bundleRelease

- name: Upload aab as artefact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.get_version.outputs.VERSION }}
files: enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar
token: ${{ secrets.GITHUB_TOKEN }}
name: app-release
path: ${{ github.workspace }}/demoscannerapp/build/outputs/bundle/debug/release/demoscannerapp-debug.aab
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
21 changes: 18 additions & 3 deletions demoscannerapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,37 @@ android {
defaultConfig {
applicationId "com.enioka.scanner.demoscannerapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
targetSdkVersion 33
versionCode 4
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}
signingConfigs {
debug {
storeFile file("debug.keystore")
storePassword System.getenv("KEYSTORE_PASSWORD")
keyAlias System.getenv("KEY_ALIAS")
keyPassword System.getenv("SIGNKEY_PASSWORD")
}
release {
storeFile file("debug.keystore")
storePassword System.getenv("KEYSTORE_PASSWORD")
keyAlias System.getenv("KEY_ALIAS")
keyPassword System.getenv("SIGNKEY_PASSWORD")
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
applicationIdSuffix ".release"
}
debug {
signingConfig signingConfigs.debug
debuggable true
applicationIdSuffix ".debug"
}
Expand Down
4 changes: 4 additions & 0 deletions demoscannerapp/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class net.sourceforge.zbar.** {
*;
}
1 change: 1 addition & 0 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json_key_file("service-account.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
59 changes: 59 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:android)

platform :android do

lane :default do
internal
end

# LANE 1
desc "Publish a new version to the Google Play (INTERNAL)"
lane :internal do

# Generate AAB file
gradle(
task: "demoscannerapp:bundle",
build_type: "Release"
)

# Upload the AAB to play store (internal track)
upload_to_play_store(
package_name: "com.enioka.scanner.demoscannerapp.release",
track: 'internal',
release_status: "draft"
)
end

# LANE 2
desc "Publish a new version to the Google Play (PRODUCTION)"
lane :release do

# Generate AAB file
gradle(
task: "demoscannerapp:bundle",
build_type: "Release"
)

# Upload the AAB to play store (internal track)
upload_to_play_store(
package_name: "com.enioka.scanner.demoscannerapp.release",
track: 'production',
release_status: "draft"
)
end
end

0 comments on commit 95e6d25

Please sign in to comment.