diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index cfeb2a6a..a841f524 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -13,22 +13,26 @@ jobs: steps: - name: Check out code uses: actions/checkout@v3.1.0 + - name: Set up JDK 17 uses: actions/setup-java@v3.5.1 with: - distribution: adopt + distribution: 'zulu' java-version: 17 + + - name: Grant Permission to Execute Gradle + run: chmod +x gradlew + - name: Release build - run: ./gradlew assemble --scan - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar --scan + run: ./gradlew assemble --scan -x :benchmark:pixel6api31Setup -x :benchmark:pixel6api31NonMinifiedReleaseAndroidTest -x :benchmark:collectNonMinifiedReleaseBaselineProfile + - name: Publish to MavenCentral - run: ./gradlew publishReleasePublicationToSonatypeRepository --scan + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-daemon --no-parallel env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} SNAPSHOT: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0d5f4976..5dfd058d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,30 +2,35 @@ name: Publish on: release: - types: [released] + types: [ released ] + workflow_dispatch: jobs: publish: - name: Release build and publish + name: Snapshot build and publish runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3.1.0 + - name: Set up JDK 17 uses: actions/setup-java@v3.5.1 with: - distribution: adopt + distribution: 'zulu' java-version: 17 + + - name: Grant Permission to Execute Gradle + run: chmod +x gradlew + - name: Release build - run: ./gradlew assemble --scan - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar --scan + run: ./gradlew assemble --scan -x :benchmark:pixel6api31Setup -x :benchmark:pixel6api31NonMinifiedReleaseAndroidTest -x :benchmark:collectNonMinifiedReleaseBaselineProfile + - name: Publish to MavenCentral - run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository --scan + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} \ No newline at end of file diff --git a/balloon-compose/build.gradle.kts b/balloon-compose/build.gradle.kts index 3fd6f671..38aff15e 100644 --- a/balloon-compose/build.gradle.kts +++ b/balloon-compose/build.gradle.kts @@ -4,15 +4,24 @@ import com.skydoves.balloon.Configuration plugins { id(libs.plugins.android.library.get().pluginId) id(libs.plugins.kotlin.android.get().pluginId) + id(libs.plugins.nexus.plugin.get().pluginId) } -rootProject.extra.apply { - set("PUBLISH_GROUP_ID", Configuration.artifactGroup) - set("PUBLISH_ARTIFACT_ID", "balloon-compose") - set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) -} +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "balloon-compose" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) -apply(from ="${rootDir}/scripts/publish-module.gradle") + pom { + name.set(artifactId) + description.set("Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.") + } +} android { compileSdk = Configuration.compileSdk diff --git a/balloon/build.gradle.kts b/balloon/build.gradle.kts index 63840a1f..895540d2 100644 --- a/balloon/build.gradle.kts +++ b/balloon/build.gradle.kts @@ -18,15 +18,24 @@ import com.skydoves.balloon.Configuration plugins { id(libs.plugins.android.library.get().pluginId) id(libs.plugins.kotlin.android.get().pluginId) + id(libs.plugins.nexus.plugin.get().pluginId) } -rootProject.extra.apply { - set("PUBLISH_GROUP_ID", Configuration.artifactGroup) - set("PUBLISH_ARTIFACT_ID", "balloon") - set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) -} +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "balloon" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) -apply(from ="${rootDir}/scripts/publish-module.gradle") + pom { + name.set(artifactId) + description.set("Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.") + } +} android { compileSdk = Configuration.compileSdk diff --git a/build.gradle.kts b/build.gradle.kts index bf2fd5c8..d66bc901 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,8 +23,6 @@ plugins { alias(libs.plugins.kotlin.binary.compatibility) } -apply(from = "${rootDir}/scripts/publish-root.gradle") - apiValidation { ignoredProjects.addAll(listOf("app", "benchmark-app")) ignoredPackages.add("com/skydoves/balloon/databinding") diff --git a/gradle.properties b/gradle.properties index 0d358d97..18ae93fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,4 +42,23 @@ android.defaults.buildfeatures.shaders=false # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library # https://developer.android.com/studio/releases/gradle-plugin#4.1-nontransitive-r-class -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +# Maven publication +POM_URL=https://github.com/skydoves/balloon/ +POM_SCM_URL=https://github.com/skydoves/balloon/ +POM_SCM_CONNECTION=scm:git:git://github.com/skydoves/balloon.git +POM_SCM_DEV_CONNECTION=scm:git:git://github.com/skydoves/balloon.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=skydoves +POM_DEVELOPER_NAME=Jaewoong Eum +POM_DEVELOPER_URL=https://github.com/skydoves/ +POM_DEVELOPER_EMAIL=skydoves2@gmail.com + +SONATYPE_HOST=DEFAULT +RELEASE_SIGNING_ENABLED=true +SONATYPE_AUTOMATIC_RELEASE=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a974da95..a14354f4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,10 @@ [versions] agp = "8.1.0" dokka = "1.8.20" -nexusPlugin = "1.3.0" kotlin = "1.9.0" kotlinBinaryCompatibility = "0.13.2" jvmTarget = "11" +nexusPlugin = "0.25.3" androidxComposeBom = "2023.08.00" androidxComposeCompiler = "1.5.1" androidxComposeConstraintLayout = "1.0.1" @@ -25,8 +25,8 @@ android-application = { id = "com.android.application", version.ref = "agp" } android-library = { id = "com.android.library", version.ref = "agp" } android-test = { id = "com.android.test", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } -nexus-plugin = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexusPlugin" } kotlin-binary-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinBinaryCompatibility" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index d50232c1..00000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,87 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'org.jetbrains.dokka' - -task androidSourcesJar(type: Jar) { - archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs - } else { - from sourceSets.main.java.srcDirs - from sourceSets.main.kotlin.srcDirs - } -} - -tasks.withType(dokkaHtmlPartial.getClass()).configureEach { - pluginsMapConfiguration.set( - ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] - ) -} - -task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { - archiveClassifier.set('javadoc') - from dokkaJavadoc.outputDirectory -} - -artifacts { - archives androidSourcesJar - archives javadocJar -} - -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId PUBLISH_GROUP_ID - artifactId PUBLISH_ARTIFACT_ID - version PUBLISH_VERSION - if (project.plugins.findPlugin("com.android.library")) { - from components.release - } else { - from components.java - } - - artifact androidSourcesJar - artifact javadocJar - - pom { - name = PUBLISH_ARTIFACT_ID - description = 'Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.' - url = 'https://github.com/skydoves/balloon' - licenses { - license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id = 'skydoves' - name = 'Jaewoong Eum' - email = "skydoves2@gmail.com" - url = "https://github.com/skydoves" - } - } - scm { - connection = 'scm:git:github.com/skydoves/balloon.git' - developerConnection = 'scm:git:ssh://github.com/skydoves/balloon.git' - url = 'https://github.com/skydoves/balloon/tree/main' - } - } - } - } - } -} - -signing { - useInMemoryPgpKeys( - rootProject.ext["signing.keyId"], - rootProject.ext["signing.key"], - rootProject.ext["signing.password"], - ) - sign publishing.publications -} diff --git a/scripts/publish-module.gradle.kts b/scripts/publish-module.gradle.kts new file mode 100644 index 00000000..64f325b4 --- /dev/null +++ b/scripts/publish-module.gradle.kts @@ -0,0 +1,13 @@ +import com.skydoves.balloon.Configuration + +apply(plugin = "com.vanniktech.maven.publish") + +rootProject.extra.apply { + val snapshot = System.getenv("SNAPSHOT").toBoolean() + val libVersion = if (snapshot) { + Configuration.snapshotVersionName + } else { + Configuration.versionName + } + set("libVersion", libVersion) +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 78d575ba..00000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,45 +0,0 @@ -import com.skydoves.balloon.Configuration - -// Create variables with empty default values -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.key"] = '' -ext["snapshot"] = '' - -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["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = 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.key"] = System.getenv('SIGNING_KEY') - ext["snapshot"] = System.getenv('SNAPSHOT') -} - -if (snapshot) { - ext["rootVersionName"] = Configuration.snapshotVersionName -} else { - ext["rootVersionName"] = Configuration.versionName -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - version = rootVersionName - } - } -}