Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
⚙️ GitHub Action | Update Increment Version Code Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
moondev03 authored Aug 6, 2024
1 parent 463f718 commit 8b7d12d
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/versioning-and-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ jobs:
run: |
# Get the current versionCode from build.gradle
VERSION_CODE=$(grep versionCode ./Nabi/presentation/build.gradle.kts | sed 's/[^0-9]*//g')
echo "Current versionCode: $VERSION_CODE"
# Increment the versionCode
NEW_VERSION_CODE=$((VERSION_CODE + 1))
echo "New versionCode: $NEW_VERSION_CODE"
# Replace the old versionCode with the new one in build.gradle
sed -i "s/versionCode $VERSION_CODE/versionCode $NEW_VERSION_CODE/" ./Nabi/presentation/build.gradle.kts
# Check if there are changes to commit
if [ $(git status --porcelain | wc -l) -gt 0 ]; then
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
Expand All @@ -39,9 +44,14 @@ jobs:
else
echo "changed=false" >> $GITHUB_ENV
fi
- name: Show git status
run: git status

- name: Push changes
if: env.changed == 'true'
run: |
echo "Pushing changes to version-update branch"
git push origin version-update
merge_version_update:
Expand All @@ -53,11 +63,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Merge version-update branch
- name: Show current branch
run: |
echo "Current branch:"
git branch
echo "Fetching remote branches"
git fetch origin
- name: Merge version-update branch
run: |
git checkout develop
git merge origin/version-update
echo "Pushing changes to develop branch"
git push origin develop
build_and_upload:
Expand All @@ -80,25 +97,35 @@ jobs:
java-version: '17'

- name: Grant execute permission for gradlew
run: chmod +x ./Nabi/gradlew
run: |
echo "Granting execute permission for gradlew"
chmod +x ./Nabi/gradlew
- name: Decode and save keystore
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > ./Nabi/presentation/keystore.jks
run: |
echo "Decoding and saving keystore"
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > ./Nabi/presentation/keystore.jks
- name: Verify keystore
run: |
echo "Listing files in ./Nabi/presentation/"
ls -alh ./Nabi/presentation/
echo "Checking JKS format..."
keytool -list -v -keystore ./Nabi/presentation/keystore.jks -storetype JKS || echo "JKS format verification failed"
- name: Create google-services.json
run: echo "$GOOGLE_SERVICES_JSON" > ./Nabi/presentation/google-services.json
run: |
echo "Creating google-services.json"
echo "$GOOGLE_SERVICES_JSON" > ./Nabi/presentation/google-services.json
- name: Create local.properties
run: echo "$LOCAL_PROPERTIES_CONTENTS" > ./Nabi/local.properties
run: |
echo "Creating local.properties"
echo "$LOCAL_PROPERTIES_CONTENTS" > ./Nabi/local.properties
- name: Build release APK
run: |
echo "Building release APK"
cd ./Nabi
./gradlew assembleRelease
Expand Down

0 comments on commit 8b7d12d

Please sign in to comment.