From 6a2c90627c6ffb590f2e220e477e770e369f39f8 Mon Sep 17 00:00:00 2001 From: bn-tw2020 Date: Sat, 4 Nov 2023 13:05:51 +0900 Subject: [PATCH] Add to Maven Setting --- .github/workflows/publish-snapshot.yml | 38 +++++++++ .github/workflows/publish.yml | 36 +++++++++ build.gradle.kts | 5 +- .../com/taewooyo/buildsrc/Configuration.kt | 2 + gradle.properties | 80 +++++++++++++++---- gradle/libs.versions.toml | 2 + scripts/publish-module.gradle.kts | 13 +++ volcano-compose/build.gradle.kts | 17 ++++ volcano/build.gradle.kts | 20 +++++ 9 files changed, 194 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/publish-snapshot.yml create mode 100644 .github/workflows/publish.yml create mode 100644 scripts/publish-module.gradle.kts diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..657b022 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,38 @@ +name: Publish Snapshot builds + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + publish: + name: Snapshot build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4.1.1 + + - name: Set up JDK 17 + uses: actions/setup-java@v3.13.0 + with: + distribution: 'zulu' + java-version: 17 + + - name: Grant Permission to Execute Gradle + run: chmod +x gradlew + + - name: Release build + run: ./gradlew assemble --scan + + - name: Publish to MavenCentral + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-daemon --no-parallel + env: + 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 \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3173cdb --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish + +on: + release: + types: [ released ] + workflow_dispatch: + +jobs: + publish: + name: Snapshot build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4.1.1 + + - name: Set up JDK 17 + uses: actions/setup-java@v3.13.0 + with: + distribution: 'zulu' + java-version: 17 + + - name: Grant Permission to Execute Gradle + run: chmod +x gradlew + + - name: Release build + run: ./gradlew assemble --scan + + - name: Publish to MavenCentral + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache + env: + 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/build.gradle.kts b/build.gradle.kts index db95fd7..36fce05 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,6 +10,7 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.nexus.plugin) alias(libs.plugins.spotless) alias(libs.plugins.kotlin.binary.compatibility) } @@ -40,6 +41,4 @@ subprojects { endWithNewline() } } -} - -group = "com.taewooyo.volcano" \ No newline at end of file +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/taewooyo/buildsrc/Configuration.kt b/buildSrc/src/main/kotlin/com/taewooyo/buildsrc/Configuration.kt index 7c40b28..e94510d 100644 --- a/buildSrc/src/main/kotlin/com/taewooyo/buildsrc/Configuration.kt +++ b/buildSrc/src/main/kotlin/com/taewooyo/buildsrc/Configuration.kt @@ -9,4 +9,6 @@ object Configuration { const val patchVersion = 0 const val versionName = "$majorVersion.$minorVersion.$patchVersion" const val versionCode = 1 + const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT" + const val artifactGroup = "io.github.taewooyo" } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3c5031e..419b3cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,71 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# +# Copyright 2023 taewooyo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory +org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dlint.nullness.ignore-deprecated=true + +# https://docs.gradle.org/current/userguide/build_cache.html +org.gradle.caching=true + # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn +org.gradle.parallel=true + +# Configure only necessary projects, useful with multimodule projects +org.gradle.configureondemand=true + +# AndroidX Migration https://developer.android.com/jetpack/androidx/migrate android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official + +# Removes uneccessary default build features +android.defaults.buildfeatures.aidl=false +android.defaults.buildfeatures.buildconfig=false +android.defaults.buildfeatures.renderscript=false +android.defaults.buildfeatures.resvalues=false +android.defaults.buildfeatures.shaders=false + # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +# https://developer.android.com/studio/releases/gradle-plugin#4.1-nontransitive-r-class +android.nonTransitiveRClass=true + +## Maven Central Publication ## +systemProp.org.gradle.internal.publish.checksums.insecure=true + +# Increase timeout when pushing to Sonatype (otherwise we get timeouts) +systemProp.org.gradle.internal.http.socketTimeout=120000 + +GROUP=com.github.taewooyo + +POM_URL=https://github.com/taewooyo/volcano/ +POM_SCM_URL=https://github.com/taewooyo/volcano/ +POM_SCM_CONNECTION=scm:git:git://github.com/taewooyo/volcano.git +POM_SCM_DEV_CONNECTION=scm:git:git://github.com/taewooyo/volcano.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=taewooyo +POM_DEVELOPER_NAME=taewooyo +POM_DEVELOPER_URL=https://github.com/taewooyo/ +POM_DEVELOPER_EMAIL=skaxodn97@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 4a02154..5a73310 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,7 @@ androidxLifecycle = "2.6.2" androidxAnnotation = "1.7.0" androidxTest = "1.5.2" spotless = "6.21.0" +nexusPlugin = "0.25.3" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } @@ -22,6 +23,7 @@ android-test = {id = "com.android.test", version.ref = "agp"} kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-binary-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinBinaryCompatibility" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } +nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" } [libraries] androidx-material = { module = "com.google.android.material:material", version.ref = "androidxMaterial" } diff --git a/scripts/publish-module.gradle.kts b/scripts/publish-module.gradle.kts new file mode 100644 index 0000000..dde4d37 --- /dev/null +++ b/scripts/publish-module.gradle.kts @@ -0,0 +1,13 @@ +import com.taewooyo.buildsrc.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) +} \ No newline at end of file diff --git a/volcano-compose/build.gradle.kts b/volcano-compose/build.gradle.kts index a074d4d..70a75df 100644 --- a/volcano-compose/build.gradle.kts +++ b/volcano-compose/build.gradle.kts @@ -4,6 +4,23 @@ import com.taewooyo.buildsrc.Configuration plugins { id(libs.plugins.android.library.get().pluginId) id(libs.plugins.kotlin.android.get().pluginId) + id(libs.plugins.nexus.plugin.get().pluginId) +} + +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "volcano-compose" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) + + pom { + name.set(artifactId) + description.set("Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.") + } } android { diff --git a/volcano/build.gradle.kts b/volcano/build.gradle.kts index 7900a1e..5b61d40 100644 --- a/volcano/build.gradle.kts +++ b/volcano/build.gradle.kts @@ -1,9 +1,29 @@ +import com.taewooyo.buildsrc.Configuration + @Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { id("java-library") id("kotlin") + id(libs.plugins.nexus.plugin.get().pluginId) +} + +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "volcano" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) + + pom { + name.set(artifactId) + description.set("Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.") + } } + java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17