From 9ca85a8a41e6e4e01cba913365c978a7a3c72354 Mon Sep 17 00:00:00 2001 From: NiazSagor Date: Sun, 1 Mar 2026 14:49:17 +0600 Subject: [PATCH 1/2] Add automated versioning and release workflow This commit introduces a GitHub Actions workflow to automate version bumping and tagging, while externalizing version configuration. - Adds a `release.yml` GitHub workflow that triggers on pushes to the `release` branch to increment the `VERSION_CODE` and `VERSION_NAME` (patch level), commit the changes, and create a corresponding Git tag. - Creates `version.properties` to store the current version metadata. - Updates `app/build.gradle.kts` to dynamically load `versionCode` and `versionName` from the `version.properties` file instead of using hardcoded values. --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ app/build.gradle.kts | 8 ++++-- version.properties | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 version.properties diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..177658b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release Version + +on: + push: + branches: + - release + +jobs: + bump-and-tag: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Bump Version + run: | + FILE=version.properties + + source $FILE + + NEW_CODE=$((VERSION_CODE + 1)) + + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NAME" + NEW_PATCH=$((PATCH + 1)) + NEW_NAME="$MAJOR.$MINOR.$NEW_PATCH" + + echo "VERSION_CODE=$NEW_CODE" > $FILE + echo "VERSION_NAME=$NEW_NAME" >> $FILE + + echo "New Version: $NEW_NAME ($NEW_CODE)" + + - name: Commit changes + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add version.properties + git commit -m "Release: bump version" + git push + + - name: Create Git Tag + run: | + source version.properties + git tag "v$VERSION_NAME" + git push origin "v$VERSION_NAME" diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6419b24..cb16ab1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,6 +16,10 @@ android { namespace = "com.byteutility.dev.leetcode.plus" compileSdk = 35 + val versionPropsFile = rootProject.file("version.properties") + val versionProps = Properties() + versionProps.load(FileInputStream(versionPropsFile)) + // Load local properties val localPropertiesFile = rootProject.file("local.properties") val localProperties = Properties() @@ -34,8 +38,8 @@ android { applicationId = "com.byteutility.dev.leetcode.plus" minSdk = 29 targetSdk = 35 - versionCode = 15 - versionName = "1.1.4" + versionCode = versionProps["VERSION_CODE"].toString().toInt() + versionName = versionProps["VERSION_NAME"].toString() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..8b934fe --- /dev/null +++ b/version.properties @@ -0,0 +1,2 @@ +VERSION_CODE=15 +VERSION_NAME=1.1.4 \ No newline at end of file From 3d35cb0e3f4b228d8b69ef4a069189f24a17ca5c Mon Sep 17 00:00:00 2001 From: NiazSagor Date: Sun, 1 Mar 2026 14:51:21 +0600 Subject: [PATCH 2/2] version update to 1.1.4 --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 8b934fe..7ec739d 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ VERSION_CODE=15 -VERSION_NAME=1.1.4 \ No newline at end of file +VERSION_NAME=1.1.4