Skip to content

Commit

Permalink
Merge pull request #84 from tw-mosip/beta-release
Browse files Browse the repository at this point in the history
feat(#INJI-173) [Adityan] Added a beta release workflow when tagged
  • Loading branch information
vijay151096 authored Jul 18, 2023
2 parents 119be83 + 3cbeb06 commit 8bbd6b8
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 64 deletions.
142 changes: 142 additions & 0 deletions .github/workflows/android-beta-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Android Beta Build

env:
backendServiceDefaultUrl: https://api.sandbox.mosip.net

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to be published'
required: true
default: 'v1.2.3'
type: string
body:
description: 'Release body message'
required: true
default: 'Changes in this Release'
type: string
pre-release:
description: 'Pre-release? True/False'
required: true
default: False
type: string
backendServiceUrl:
description: 'Backend service URL'
required: true
default: 'https://api.sandbox.mosip.net'
type: string
theme:
description: 'Application Theme'
required: true
default: 'orange'
type: choice
options:
- orange
- purple
buildDescription:
description: 'What to test'
required: true
default: 'QA-Triple environment'
type: string
registry_edit:
description: 'Edit Registry'
required: true
default: 'true'
type: choice
options:
- false
- true

jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-node@v3
with:
node-version: '16.x'

- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
body: ${{ github.event.inputs.body }}
draft: false
prerelease: ${{fromJSON(github.event.inputs.pre-release)}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check for git tag
run: |
cd android/scripts
./git-tag.sh
- name: Install npm dependencies
run: |
npm ci
- name: Create .env.local file
run: |
echo "${{ secrets.ENV_FILE }}" > .env.local > android/local.properties
- name: Setup branch and env
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- name: Setup branch and GPG public key
run: |
# Strip git ref prefix from version
echo ${{ env.BRANCH_NAME }}
echo ${{ env.GPG_TTY }}
sudo apt-get --yes install gnupg2
gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg
gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg
- name: Setup Firebase
run: |
cd android
if [ ! -z "$FIREBASE_SECRET" ] && [ -f app/google-services.json.gpg ];then rm -f app/google-services.json;gpg2 --quiet --batch --passphrase=$FIREBASE_SECRET --pinentry-mode loopback --decrypt --output app/google-services.json app/mosip-google-services.json.gpg;fi
env:
FIREBASE_SECRET: ${{ secrets.GPG_SECRET }}

- name: Generate keystore
run: |
echo "$ANDROID_KEYSTORE_FILE" > release.keystore.b64
base64 -d -i release.keystore.b64 > android/app/release.keystore
env:
ANDROID_KEYSTORE_FILE: ${{ secrets.INJI_ANDROID_RELEASE_KEYSTORE }}

- name: Export variables for keystore
run: |
cd android/app
export RELEASE_KEYSTORE_ALIAS=androidreleasekey
export RELEASE_KEYSTORE_PASSWORD=$RELEASE_KEYSTORE_PASSWORD
env:
RELEASE_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_RELEASE_STOREPASS}}'

- name: Create Google Play Config file
run : |
cd android
echo "$INJI_ANDROID_PLAY_STORE_CONFIG_JSON" > play_config.json.b64
base64 -d -i play_config.json.b64 > play_config.json
env:
INJI_ANDROID_PLAY_STORE_CONFIG_JSON: ${{ secrets.INJI_ANDROID_PLAY_STORE_CONFIG_JSON }}

- name: Run Build
run: |
cd android/scripts
./beta-build.sh
env:
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
APPLICATION_THEME: ${{ github.event.inputs.theme }}
RELEASE_KEYSTORE_ALIAS: androidreleasekey
RELEASE_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_RELEASE_STOREPASS}}'
SLACK_URL: '${{ secrets.SLACK_WEBHOOK_DEVOPS }}'
PLAY_CONSOLE_RELEASE_DESCRIPTION: ${{ github.event.inputs.buildDescription }}
CREDENTIAL_REGISTRY_EDIT: ${{ github.event.inputs.registry_edit }}
8 changes: 3 additions & 5 deletions .github/workflows/android-build-verify.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR - android build verification
name: PR - Android build verification

env:
backendServiceDefaultUrl: https://api.sandbox.mosip.net
Expand Down Expand Up @@ -107,10 +107,8 @@ jobs:

- name: Run Build using Fastlane
run: |
cd android
yes | sudo gem install bundler
yes | sudo fastlane install_plugins
bundle exec fastlane android_build_verify
cd android/scripts
./verify-build.sh
env:
DEBUG_KEYSTORE_ALIAS: androiddebugkey
DEBUG_KEYSTORE_PASSWORD: '${{secrets.INJI_ANDROID_DEBUG_STOREPASS}}'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android Custom Build
name: Android Internal Build

env:
backendServiceDefaultUrl: https://api.sandbox.mosip.net
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Run Build
run: |
cd android/scripts
./run-fastlane.sh
./internal-build.sh
env:
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
APPLICATION_THEME: ${{ github.event.inputs.theme }}
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/tag.yaml

This file was deleted.

15 changes: 8 additions & 7 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);

androidGitVersion {
baseCode 1
baseCode 0
codeFormat 'MXXNXXPXX'
format '% tag %%commit_%%branch%'
}

Expand All @@ -143,7 +144,7 @@ android {
APP_NAME_RELEASE = "@string/app_name"
APP_NAME_PH = "@string/app_name_ph"
APP_NAME_MOSIP = "@string/app_name_mosip"
APP_NAME_NEWLOGIC = "@string/app_name_newlogic"
APP_NAME_BETA = "@string/app_name_beta"
}

compileOptions {
Expand All @@ -156,7 +157,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionName androidGitVersion.name()
versionCode 1
versionCode androidGitVersion.code()

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
Expand Down Expand Up @@ -219,16 +220,16 @@ android {

productFlavors {
mosip {
versionName defaultConfig.versionName + "-mosip"
versionName defaultConfig.versionName
manifestPlaceholders = [
APP_NAME: APP_NAME_MOSIP
]
dimension "inji"
}
newlogic {
versionName defaultConfig.versionName + "-newlogic"
beta {
versionName defaultConfig.versionName
manifestPlaceholders = [
APP_NAME: APP_NAME_NEWLOGIC
APP_NAME: APP_NAME_BETA
]
dimension "inji"
}
Expand Down
29 changes: 22 additions & 7 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ lane :android_build_verify do
)
end

desc "Build for Android"
lane :android_build do
gradle(
task: "assembleMosipRelease",
)
end

desc "Deploy an Internal testing version to the Google Play"
lane :android_build_internal do
previous_build_number = google_play_track_version_codes(
Expand Down Expand Up @@ -56,3 +49,25 @@ lane :android_build_internal do
default_payloads: [:git_branch, :last_git_commit]
)
end

desc "Deploy an Beta version to the Google Play"
lane :android_build_beta do

git_tag = sh('git describe --abbrev=0 --tags --exact-match HEAD').strip

versionName = "Inji #{git_tag}"

gradle(task: "clean bundleBetaRelease")
upload_to_play_store(
track: 'alpha',
release_status: 'completed',
version_name: versionName,
)

slack(
message: "Inji [Beta]- #{versionName} is uploaded to Play store. Description : #{PLAY_CONSOLE_RELEASE_DESCRIPTION}.",
success: true,
slack_url: "#{SLACK_URL}",
default_payloads: [:git_branch, :last_git_commit]
)
end
7 changes: 7 additions & 0 deletions android/scripts/beta-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd ..

yes | sudo gem install bundler

yes | sudo fastlane install_plugins

bundle exec fastlane android_build_beta
10 changes: 10 additions & 0 deletions android/scripts/git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

TAG=$(git describe --abbrev=0 --tags --exact-match HEAD 2>/dev/null)

if [[ -z "$TAG" ]]; then
echo "No tag found for the current commit. Please provide a Tag to proceed with the Build."
exit 1
else
echo "Tag for the current commit: $TAG"
fi
File renamed without changes.
7 changes: 7 additions & 0 deletions android/scripts/verify-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd ..

yes | sudo gem install bundler

yes | sudo fastlane install_plugins

bundle exec fastlane android_build_verify

0 comments on commit 8bbd6b8

Please sign in to comment.