diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 8f281843..bb04eb8c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,8 +10,20 @@ jobs: steps: - name: Checkout project sources uses: actions/checkout@v3 + + - name: Set up JDK and Maven Central + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + cache: 'gradle' + server-id: central + server-username: ${{ secrets.MAVEN_USERNAME }} + server-password: ${{ secrets.MAVEN_PASSWORD }} + - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Setup local.properties run: | cat << EOF >> local.properties @@ -23,15 +35,17 @@ jobs: contentType="${{ secrets.CONTENT_TYPE }}" assetUid="${{ secrets.ASSET_UID }}" EOF + - name: Gradle build and clean run: | ./gradlew clean build - - name: Publish the SDK + + - name: Publish to Maven Central run: | ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.mavenCentralUsername }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.mavenCentralPassword }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }} ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.signingInMemoryKey }} ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.signingInMemoryKeyId }} ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.signingInMemoryKeyPassword }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index dfe2f5ec..91743a3f 100644 --- a/build.gradle +++ b/build.gradle @@ -12,8 +12,7 @@ buildscript { } dependencies { - //classpath "com.android.tools.build:gradle:8.2.1" //8.2.1 - classpath 'com.android.tools.build:gradle:7.4.2' + classpath "com.android.tools.build:gradle:8.2.1" classpath 'io.github.gradle-nexus:publish-plugin:2.0.0-rc-1' classpath "org.jacoco:org.jacoco.core:$jacoco_version" } diff --git a/contentstack/build.gradle b/contentstack/build.gradle index decfc052..25ab9afb 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -1,62 +1,20 @@ plugins { - id "com.vanniktech.maven.publish" version "0.27.0" id "com.android.library" + id "com.vanniktech.maven.publish" version "0.33.0" } -import com.vanniktech.maven.publish.SonatypeHost - -android.buildFeatures.buildConfig true - -mavenPublishing { - publishToMavenCentral(SonatypeHost.DEFAULT) - signAllPublications() - coordinates("com.contentstack.sdk", "android", "4.1.0") - - pom { - name = "contentstack-android" - description = "The Content Delivery SDK facilitates the retrieval of content from your Contentstack account, enabling seamless delivery to your web or mobile properties.." - inceptionYear = "2018" - packaging 'aar' - url = "https://github.com/contentstack/contentstack-android" - licenses { - license { - name = "The MIT License" - url = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" - distribution = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" - } - } - developers { - developer { - id = "ishaileshmishra" - name = "contentstack" - url = "https://github.com/contentstack/contentstack-android" - } - } - scm { - url = "scm:git@github.com:contentstack/contentstack-android" - connection = "scm:git:git://github.com/contentstack/contentstack-android.git" - developerConnection = "scm:git@github.com:contentstack/contentstack-android.git" - } - } -} - - -tasks.register('jacocoTestReport', JacocoReport) { - dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] - reports { - html.enabled = true - } - afterEvaluate { - classDirectories.setFrom(files(classDirectories.files.collect { - fileTree(dir: it, exclude: '**com/contentstack/okhttp**') - fileTree(dir: it, exclude: '**com/contentstack/okio**') - fileTree(dir: it, exclude: '**com/contentstack/txtmark**') - })) - } +ext { + PUBLISH_GROUP_ID = 'com.contentstack.sdk' + PUBLISH_ARTIFACT_ID = 'android' + PUBLISH_VERSION = '4.1.0' } android { - //namespace "com.contentstack.sdk" + namespace "com.contentstack.sdk" + compileSdk 34 // Using latest stable Android SDK version + buildFeatures { + buildConfig true + } packagingOptions { exclude("META-INF/DEPENDENCIES") exclude("META-INF/LICENSE") @@ -97,7 +55,6 @@ android { keyPassword 'android' } } - compileSdk 30 defaultConfig { // Required when setting minSdkVersion to 20 or lower multiDexEnabled true @@ -204,4 +161,61 @@ tasks.register('createJar', Jar) { include 'com/contentstack/' //include 'META-INF/' } -createJar.dependsOn(clearJar, unzip, build) \ No newline at end of file +createJar.dependsOn(clearJar, unzip, build) + +mavenPublishing { + // Configure the Maven Central publishing target + publishToMavenCentral("CENTRAL_PORTAL") + + // Sign all publications + signAllPublications() + + coordinates(PUBLISH_GROUP_ID, PUBLISH_ARTIFACT_ID, PUBLISH_VERSION) + + pom { + name = "contentstack-android" + description = "The Content Delivery SDK facilitates the retrieval of content from your Contentstack account, enabling seamless delivery to your web or mobile properties.." + inceptionYear = "2018" + packaging 'aar' + url = "https://github.com/contentstack/contentstack-android" + licenses { + license { + name = "The MIT License" + url = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" + distribution = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" + } + } + developers { + developer { + id = "ishaileshmishra" + name = "contentstack" + url = "https://github.com/contentstack/contentstack-android" + } + } + scm { + url = "scm:git@github.com:contentstack/contentstack-android" + connection = "scm:git:git://github.com/contentstack/contentstack-android.git" + developerConnection = "scm:git@github.com:contentstack/contentstack-android.git" + } + } +} + +tasks.register('jacocoTestReport', JacocoReport) { + dependsOn('testDebugUnitTest', 'createDebugCoverageReport') + reports { + html.required = true + } +} + +// Configure jacocoTestReport after evaluation when classDirectories is available +project.afterEvaluate { + tasks.named('jacocoTestReport', JacocoReport) { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: [ + '**com/contentstack/okhttp**', + '**com/contentstack/okio**', + '**com/contentstack/txtmark**' + ]) + })) + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 64b7045d..e3822e8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,14 @@ android.useAndroidX=true android.enableJetifier=true android.enableR8.fullMode=false -org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m \ No newline at end of file +org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m +android.suppressUnsupportedCompileSdk=34 + +# Maven Central Publishing Configuration +# These values should be provided by environment variables in CI +# For new Central Portal, use Portal Token instead of username/password +mavenCentralUsername= +mavenCentralPassword= +signing.keyId= +signing.password= +signing.secretKeyRingFile= \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b0e6c07..536def26 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,7 +2,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists #distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip #distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index f699c255..68046e7a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,3 +17,9 @@ dependencyResolutionManagement { } rootProject.name = "contentstack-android" include ':contentstack' + +gradle.beforeProject { project -> + if (project.name == "contentstack") { + project.ext.ANDROID_VARIANT_TO_PUBLISH = "release" + } +}