Skip to content

Commit

Permalink
ANDROID-11221 Update plugin to upload to mavencentral (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmartinbTEF authored Mar 28, 2023
1 parent 025d908 commit c108524
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
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 }}
MOBILE_MAVENCENTRAL_PASSWORD: ${{ secrets.MOBILE_MAVENCENTRAL_PASSWORD }}
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"
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 9 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) {
Expand All @@ -47,3 +41,4 @@ allprojects {
version = System.getProperty("LIBRARY_VERSION") ?: "undefined"
}
}
apply from: "${rootProject.projectDir}/publish_maven_central.gradle"
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
13 changes: 0 additions & 13 deletions mavencentral.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions publish_maven_central.gradle
Original file line number Diff line number Diff line change
@@ -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")
}
}
}

0 comments on commit c108524

Please sign in to comment.