From c1085249b4906b01d8c8374da686f2a555138d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADn?= Date: Tue, 28 Mar 2023 16:30:15 +0200 Subject: [PATCH] ANDROID-11221 Update plugin to upload to mavencentral (#6) --- .github/workflows/release.yml | 21 ++++++--------------- .github/workflows/tests.yml | 10 +++++++++- build.gradle | 23 +++++++++-------------- gradle/wrapper/gradle-wrapper.properties | 2 +- mavencentral.gradle | 13 ------------- publish_maven_central.gradle | 11 +++++++++++ 6 files changed, 36 insertions(+), 44 deletions(-) create mode 100644 publish_maven_central.gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a7a41f..6edc133 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,17 @@ name: "Create release" -on: +on: release: - types: [published] + types: [published] jobs: release: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v2 - + - name: Build library run: 'bash ./gradlew clean :nestedscrollwebview:assembleRelease' - + - name: Release library env: MOBILE_MAVENCENTRAL_USER: ${{ secrets.MOBILE_MAVENCENTRAL_USER }} @@ -19,14 +19,5 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }} - run: "bash ./gradlew publishReleasePublicationToSonatypeRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }}" - - - name: Wait 1 minute until the artifacts are ready in maven central - run: sleep 60s - shell: bash - - - name: Close and promote staging repository - env: - MOBILE_MAVENCENTRAL_USER: ${{ secrets.MOBILE_MAVENCENTRAL_USER }} - MOBILE_MAVENCENTRAL_PASSWORD: ${{ secrets.MOBILE_MAVENCENTRAL_PASSWORD }} - run: 'bash ./gradlew closeAndReleaseRepository' + run: "bash ./gradlew publishReleasePublicationToSonatypeRepository -DLIBRARY_VERSION=${{ github.event.release.tag_name }} + --max-workers 1 closeAndReleaseStagingRepository" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cc50186..5852591 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,4 +22,12 @@ jobs: wrapper-cache-enabled: false dependencies-cache-enabled: false configuration-cache-enabled: false - arguments: assembleRelease check detekt + arguments: assembleRelease + + - name: Run checks + if: success() || failure() + run: ./gradlew check + + - name: Run Detekt + if: success() || failure() + run: ./gradlew detekt diff --git a/build.gradle b/build.gradle index ead72f9..06e7458 100644 --- a/build.gradle +++ b/build.gradle @@ -1,21 +1,24 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { dependencies { + classpath "com.android.tools.build:gradle:7.1.3" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0" classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" } } plugins { - id 'com.android.application' version '7.2.2' apply false - id 'com.android.library' version '7.2.2' apply false - id 'org.jetbrains.kotlin.android' version '1.6.10' apply false - id 'io.gitlab.arturbosch.detekt' version '1.18.1' + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false + id 'org.jetbrains.kotlin.android' version '1.6.21' apply false + id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' apply false + id 'io.gitlab.arturbosch.detekt' version '1.22.0' } detekt { input = files(rootProject.rootDir) config = files("$projectDir/detekt.yml") - failFast = true + allRules = true buildUponDefaultConfig = true reports { @@ -30,15 +33,6 @@ task clean(type: Delete) { delete rootProject.buildDir } -apply plugin: 'io.codearte.nexus-staging' - -nexusStaging { - packageGroup = "com.telefonica" - stagingProfileId = "f7fe7699e57a" - username = System.getenv("MOBILE_MAVENCENTRAL_USER") - password = System.getenv("MOBILE_MAVENCENTRAL_PASSWORD") -} - allprojects { group = 'com.telefonica.nestedscrollwebview' if (System.getProperty("SNAPSHOT_VERSION") != null) { @@ -47,3 +41,4 @@ allprojects { version = System.getProperty("LIBRARY_VERSION") ?: "undefined" } } +apply from: "${rootProject.projectDir}/publish_maven_central.gradle" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a27a70e..93771eb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed Aug 03 11:27:29 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/mavencentral.gradle b/mavencentral.gradle index e859832..9d47ad0 100644 --- a/mavencentral.gradle +++ b/mavencentral.gradle @@ -65,19 +65,6 @@ publishing { } } } - repositories { - maven { - name = "sonatype" - - def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - credentials { - username System.getenv("MOBILE_MAVENCENTRAL_USER") - password System.getenv("MOBILE_MAVENCENTRAL_PASSWORD") - } - } - } } signing { diff --git a/publish_maven_central.gradle b/publish_maven_central.gradle new file mode 100644 index 0000000..1d8d625 --- /dev/null +++ b/publish_maven_central.gradle @@ -0,0 +1,11 @@ +apply plugin: 'io.github.gradle-nexus.publish-plugin' + +nexusPublishing { + repositories { + sonatype { + stagingProfileId = "f7fe7699e57a" + username = System.getenv("MOBILE_MAVENCENTRAL_USER") + password = System.getenv("MOBILE_MAVENCENTRAL_PASSWORD") + } + } +}