From 782d37efd8af972134a79425b0d13a088ef11870 Mon Sep 17 00:00:00 2001 From: Karthik Gangineni Date: Mon, 3 Nov 2025 15:01:12 -0600 Subject: [PATCH 1/2] * fix error in sync main to develop * makes unreleased text case insensitive * snapshot is removed from version name * version is moved to version.properties * snapshot is added in version name dynamically based on environment variable in action.yml * sets SNAPSHOT_BUILD to true in release_snapshot.yml --- .github/actions/publish_all_modules/action.yml | 3 ++- .github/workflows/release.yml | 4 ++-- .github/workflows/release_snapshot.yml | 4 +++- build.gradle | 16 ++++++++++++++-- version.properties | 3 +++ 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 version.properties diff --git a/.github/actions/publish_all_modules/action.yml b/.github/actions/publish_all_modules/action.yml index 6ca22a8f0..0e371e71e 100644 --- a/.github/actions/publish_all_modules/action.yml +++ b/.github/actions/publish_all_modules/action.yml @@ -32,4 +32,5 @@ runs: SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_pwd }} SIGNING_KEY_ID: ${{ inputs.signing_key_id }} SIGNING_KEY_PASSWORD: ${{ inputs.signing_key_pwd }} - SIGNING_KEY_FILE: ${{ inputs.signing_key_file }} \ No newline at end of file + SIGNING_KEY_FILE: ${{ inputs.signing_key_file }} + SNAPSHOT_BUILD: ${{ env.SNAPSHOT_BUILD }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 70c04a07c..51b7ef874 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -212,7 +212,7 @@ jobs: VERSION="${{ needs.extract_version.outputs.version }}" BRANCH_NAME="sync-main-to-develop-$VERSION" PR_TITLE="Sync: Main to Develop after release $VERSION" - PR_BODY ="This PR syncs changes from the main branch to the develop branch after release of $VERSION" + PR_BODY="This PR syncs changes from the main branch to the develop branch after release of $VERSION" # Create new branch from main git checkout main @@ -227,7 +227,7 @@ jobs: --base develop \ --head $BRANCH_NAME \ --title "$PR_TITLE" \ - --body-file pr_body.md) + --body "$PR_BODY") echo "Created PR: $PR_URL" diff --git a/.github/workflows/release_snapshot.yml b/.github/workflows/release_snapshot.yml index 7387f46f9..4e697cc8c 100644 --- a/.github/workflows/release_snapshot.yml +++ b/.github/workflows/release_snapshot.yml @@ -121,8 +121,10 @@ jobs: with: signing_key_file: ${{ secrets.SIGNING_KEY_FILE }} signing_file_path: ${{ env.SIGNING_KEY_FILE_PATH }} - - name: Publish All Modules + - name: Publish All Modules with SNAPSHOT suffix uses: ./.github/actions/publish_all_modules + env: + SNAPSHOT_BUILD: true with: sonatype_usr: ${{ secrets.SONATYPE_NEXUS_USERNAME }} sonatype_pwd: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} diff --git a/build.gradle b/build.gradle index c94d48cce..4046ac8b4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,18 @@ buildscript { + def versionProps = new Properties() + file("version.properties").withInputStream { versionProps.load(it) } + + def major = versionProps.getProperty("major") + def minor = versionProps.getProperty("minor") + def patch = versionProps.getProperty("patch") + + // Add -SNAPSHOT suffix if it's snapshot publish + def isSnapshotBuild = System.getenv('SNAPSHOT_BUILD') == 'true' + def suffix = isSnapshotBuild ? '-SNAPSHOT' : '' + def sdkVersion = "${major}.${minor}.${patch}${suffix}" + ext.modules = [ - "sdkVersionName" : "2.3.0-SNAPSHOT", + "sdkVersionName": sdkVersion, "demoAppVersionCode" : 4, "androidMinSdkVersion": 23, "androidTargetVersion": 35, @@ -148,7 +160,7 @@ task updateCHANGELOGVersion { def date = new Date() def formattedDate = date.format('yyyy-MM-dd') def changelogFile = new File('CHANGELOG.md') - def changelogFileText = changelogFile.text.replaceFirst("## unreleased", "## " + versionParam + " ($formattedDate)") + def changelogFileText = changelogFile.text.replaceFirst(/(?i)## unreleased/, "## " + versionParam + " ($formattedDate)") changelogFile.write(changelogFileText) } } diff --git a/version.properties b/version.properties new file mode 100644 index 000000000..bf762fda4 --- /dev/null +++ b/version.properties @@ -0,0 +1,3 @@ +major=2 +minor=2 +patch=1 \ No newline at end of file From ffe9b26301f3700be85c673a16fc5e842e835ff6 Mon Sep 17 00:00:00 2001 From: Karthik Gangineni Date: Tue, 4 Nov 2025 10:56:51 -0600 Subject: [PATCH 2/2] * update version.properties to current version * modify changeReleaseVersion task to update version.properties --- build.gradle | 32 +++++++++++++++++++++++++++----- version.properties | 4 ++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 4046ac8b4..5a6971eb4 100644 --- a/build.gradle +++ b/build.gradle @@ -24,6 +24,13 @@ buildscript { ] } +// Function to load version properties (reusable) +def loadVersionProperties() { + def versionProps = new Properties() + file("version.properties").withInputStream { versionProps.load(it) } + return versionProps +} + plugins { alias libs.plugins.android.application apply false alias libs.plugins.android.library apply false @@ -124,11 +131,26 @@ task incrementSnapshotVersion { //./gradlew -PversionParam=0.0.1 changeReleaseVersion task changeReleaseVersion { doLast { - def topLevelGradleFile = file('./build.gradle') - def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8') - def updatedScript = - topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + '",') - topLevelGradleFile.write(updatedScript, 'UTF-8') + def versionPropsFile = file('./version.properties') + def versionProps = loadVersionProperties() + + // Parse the version parameter (e.g., "2.3.0") + def versionParts = versionParam.tokenize('.') + if (versionParts.size() != 3) { + throw new GradleException("Version parameter must be in format major.minor.patch (e.g., 2.3.0)") + } + + // Update the version properties + versionProps.setProperty('major', versionParts[0]) + versionProps.setProperty('minor', versionParts[1]) + versionProps.setProperty('patch', versionParts[2]) + + // Write back to version.properties file + versionPropsFile.withOutputStream { + versionProps.store(it, "Updated by changeReleaseVersion task") + } + + println "Updated version.properties to ${versionParam}" } } diff --git a/version.properties b/version.properties index bf762fda4..835e0f9eb 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,3 @@ major=2 -minor=2 -patch=1 \ No newline at end of file +minor=3 +patch=0 \ No newline at end of file