Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/actions/publish_all_modules/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
SIGNING_KEY_FILE: ${{ inputs.signing_key_file }}
SNAPSHOT_BUILD: ${{ env.SNAPSHOT_BUILD }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
48 changes: 41 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,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
Expand Down Expand Up @@ -112,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}"
}
}

Expand Down Expand Up @@ -148,7 +182,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)
}
}
3 changes: 3 additions & 0 deletions version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
major=2
minor=3
patch=0
Loading