diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e90224 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: [develop, main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Assemble, test and lint + run: ./gradlew assembleDebug test ktlintCheck lint --stacktrace + + - name: Upload test reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-reports + path: | + **/build/reports/tests/ + **/build/reports/lint-results-*.html + if-no-files-found: ignore diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fcd717e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 21 + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Publish to Maven Central + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + SIGNING_SECRET_KEY_RING_FILE_BASE64: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE_BASE64 }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: | + echo "$SIGNING_SECRET_KEY_RING_FILE_BASE64" | base64 --decode > "$RUNNER_TEMP/secring.gpg" + ./gradlew publishToMavenCentral --no-configuration-cache --stacktrace \ + "-Psigning.keyId=$SIGNING_KEY_ID" \ + "-Psigning.password=$SIGNING_PASSWORD" \ + "-Psigning.secretKeyRingFile=$RUNNER_TEMP/secring.gpg" diff --git a/README.md b/README.md index d4e04b7..293e0d2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Awesome App Rating -[![Build Status](https://app.bitrise.io/app/3156ba39c3e19393/status.svg?token=xXPr-IjWuLLKVliX5QPZKg&branch=develop)](https://app.bitrise.io/app/3156ba39c3e19393) +[![CI](https://github.com/SuddenH4X/awesome-app-rating/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/SuddenH4X/awesome-app-rating/actions/workflows/ci.yml) A highly customizable Android library providing a dialog, which asks the user to rate the app. If the user rates below the defined threshold, the dialog will show a feedback form or ask the user to mail his feedback. Otherwise it will ask the user to rate the app in the Google Play Store. diff --git a/build.gradle.kts b/build.gradle.kts index 77301ee..0a4b9dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,8 @@ -apply(from = "${rootDir}/scripts/publish-root.gradle") - plugins { alias(libs.plugins.android.application) apply false - alias(libs.plugins.gradle.nexus.publish) alias(libs.plugins.jlleitschuh.gradle.ktlint) apply false alias(libs.plugins.kotlin.compose.compiler) apply false + alias(libs.plugins.vanniktech.maven.publish) apply false } buildscript { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5981e34..a20cbdc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ compileSdk = "36" jvmToolchain = "21" kotlin = "2.3.21" minSdk = "23" -targetSdk = "35" +targetSdk = "36" androidxActivityCompose = "1.13.0" androidxAnnotation = "1.10.0" @@ -14,8 +14,8 @@ androidxConstraintlayout = "2.2.1" androidxCore = "1.16.0" # Don't upgrade to 1.17.0 or higher because of compileSdk 36 requirement googleMaterial = "1.14.0" googlePlayReview = "2.0.2" -gradleNexusPublish = "2.0.0" ktlint = "14.2.0" +vanniktechMavenPublish = "0.36.0" # Dependencies for testing mannodermausJunit5 = "2.0.1" @@ -47,7 +47,7 @@ testing-mockk = { module = "io.mockk:mockk", version.ref = "testingMockk" } [plugins] android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } -gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradleNexusPublish" } jlleitschuh-gradle-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } mannodermaus-android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "mannodermausJunit5" } +vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish" } diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 2721a1b..7ce052a 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -4,6 +4,7 @@ plugins { id(libs.plugins.android.library.get().pluginId) alias(libs.plugins.mannodermaus.android.junit5) alias(libs.plugins.jlleitschuh.gradle.ktlint) + alias(libs.plugins.vanniktech.maven.publish) } val version = "2.8.0" @@ -38,11 +39,6 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } - - // Workaround for https://github.com/gradle-nexus/publish-plugin/issues/208 - publishing { - singleVariant("release") - } } dependencies { @@ -68,24 +64,36 @@ afterEvaluate { } } -ext { - set("PUBLISH_GROUP_ID", "com.suddenh4x.ratingdialog") - set("PUBLISH_VERSION", version) - set("PUBLISH_ARTIFACT_ID", "awesome-app-rating") - set( - "PUBLISH_DESCRIPTION", - "A highly customizable Android library providing a dialog, which asks the user to rate the app or give feedback. You can also use the" + - "library to show the Google in-app review easily under certain conditions.", - ) - set("PUBLISH_URL", "https://github.com/SuddenH4X/awesome-app-rating") - set("PUBLISH_LICENSE_NAME", "Apache License") - set("PUBLISH_LICENSE_URL", "https://github.com/SuddenH4X/awesome-app-rating/blob/master/LICENSE") - set("PUBLISH_DEVELOPER_ID", "SuddenH4X") - set("PUBLISH_DEVELOPER_NAME", "Sascha Kühne") - set("PUBLISH_DEVELOPER_EMAIL", "SuddenH4X@users.noreply.github.com") - set("PUBLISH_SCM_CONNECTION", "scm:git:github.com/SuddenH4X/awesome-app-rating.git") - set("PUBLISH_SCM_DEVELOPER_CONNECTION", "scm:git:ssh://github.com:SuddenH4X/awesome-app-rating.git") - set("PUBLISH_SCM_URL", "https://github.com/SuddenH4X/awesome-app-rating/tree/master") -} +mavenPublishing { + publishToMavenCentral(automaticRelease = true) + signAllPublications() -apply(from = "${rootProject.projectDir}/scripts/publish-module.gradle") + coordinates("com.suddenh4x.ratingdialog", "awesome-app-rating", version) + + pom { + name.set("awesome-app-rating") + description.set( + "A highly customizable Android library providing a dialog, which asks the user to rate the app or give " + + "feedback. You can also use the library to show the Google in-app review easily under certain conditions.", + ) + url.set("https://github.com/SuddenH4X/awesome-app-rating") + licenses { + license { + name.set("Apache License") + url.set("https://github.com/SuddenH4X/awesome-app-rating/blob/master/LICENSE") + } + } + developers { + developer { + id.set("SuddenH4X") + name.set("Sascha Kühne") + email.set("SuddenH4X@users.noreply.github.com") + } + } + scm { + url.set("https://github.com/SuddenH4X/awesome-app-rating/tree/master") + connection.set("scm:git:github.com/SuddenH4X/awesome-app-rating.git") + developerConnection.set("scm:git:ssh://github.com:SuddenH4X/awesome-app-rating.git") + } + } +} diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index f293bfe..0000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,77 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -tasks.register('androidSourcesJar', Jar) { - archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - from android.sourceSets.main.java.srcDirs - } else { - from sourceSets.main.java.srcDirs - } -} - -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - // The coordinates of the library, being set from variables that - // we'll set up later - groupId = PUBLISH_GROUP_ID - artifactId = PUBLISH_ARTIFACT_ID - version = PUBLISH_VERSION - - // Two artifacts, the `aar` (or `jar`) and the sources - if (project.plugins.findPlugin("com.android.library")) { - from components.release - } else { - artifact("${layout.buildDirectory}/libs/${project.getName()}-${version}.jar") - } - - artifact androidSourcesJar - - // Mostly self-explanatory metadata - pom { - name = PUBLISH_ARTIFACT_ID - description = PUBLISH_DESCRIPTION - url = PUBLISH_URL - licenses { - license { - name = PUBLISH_LICENSE_NAME - url = PUBLISH_LICENSE_URL - } - } - developers { - developer { - id = PUBLISH_DEVELOPER_ID - name = PUBLISH_DEVELOPER_NAME - email = PUBLISH_DEVELOPER_EMAIL - } - } - - // Version control info - if you're using GitHub, follow the - // format as seen here - scm { - connection = PUBLISH_SCM_CONNECTION - developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION - url = PUBLISH_SCM_URL - } - } - } - } - } -} - -if (rootProject.ext.hasProperty("signing.keyId")) { - ext["signing.keyId"] = rootProject.ext["signing.keyId"] ?: "" - ext["signing.password"] = rootProject.ext["signing.password"] - ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] -} else { - println "signing.keyId not found in project." -} - -signing { - sign publishing.publications -} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 32508b5..0000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Create variables with empty default values -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.secretKeyRingFile"] = '' -ext["ossrhToken"] = '' -ext["ossrhTokenPassword"] = '' -ext["sonatypeStagingProfileId"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - ext["ossrhToken"] = System.getenv('OSSRH_USERNAME') - ext["ossrhTokenPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') - ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhToken - password = ossrhTokenPassword - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -}