From 16d7c49287e897ed0ce879e7ab1019a1e31bb99a Mon Sep 17 00:00:00 2001 From: dpastor Date: Fri, 5 Aug 2022 14:53:24 +0200 Subject: [PATCH 1/2] ANDROID-10730 Create GA workflows and mavenCentral publishing --- .github/release.yml | 17 ++++++ .github/workflows/manual_release.yml | 25 ++++++++ .github/workflows/release.yml | 32 ++++++++++ .github/workflows/snapshot.yml | 25 ++++++++ .github/workflows/tests.yml | 32 ++++++++++ mavencentral.gradle | 89 ++++++++++++++++++++++++++++ nestedscrollwebview/build.gradle | 1 - 7 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/manual_release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/snapshot.yml create mode 100644 .github/workflows/tests.yml create mode 100644 mavencentral.gradle diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..4b523de --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,17 @@ +changelog: + exclude: + labels: + - ignore-for-release + authors: + - tuentisre + categories: + - title: Breaking Changes 🛠 + labels: + - breaking-change + - title: New Features 🎉 + labels: + - enhancement + - new-feature + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/manual_release.yml b/.github/workflows/manual_release.yml new file mode 100644 index 0000000..32731d2 --- /dev/null +++ b/.github/workflows/manual_release.yml @@ -0,0 +1,25 @@ +name: "Release manually" +on: + workflow_dispatch: + inputs: + libraryVersion: + description: "Library version" + required: true +jobs: + manual-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 manually + 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.inputs.libraryVersion }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9b59adc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: "Create release" +on: + release: + 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' diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..57d51c9 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,25 @@ +name: "Snapshot" +on: + workflow_dispatch: + inputs: + snapshotVersion: + description: "Snapshot version" + required: true +jobs: + snapshot: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Build library + run: 'bash ./gradlew clean :nestedscrollwebview:assembleRelease' + + - name: Release snapshot + 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 -DSNAPSHOT_VERSION=${{ github.event.inputs.snapshotVersion }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..431372a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,32 @@ +name: Tests +on: pull_request +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.5 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: '11' + +# - name: Assemble +# run: ./gradlew assembleDebug +# - name: Lint +# run: ./gradlew lint +# - name: Unit Tests +# run: ./gradlew test + + ## Build all our Build Types at once ## + - name: Build all artifacts + id: buildAllApks + uses: eskatos/gradle-command-action@v1.3.3 + with: + gradle-version: current + wrapper-cache-enabled: false + dependencies-cache-enabled: false + configuration-cache-enabled: false + arguments: assembleRelease check detekt \ No newline at end of file diff --git a/mavencentral.gradle b/mavencentral.gradle new file mode 100644 index 0000000..e859832 --- /dev/null +++ b/mavencentral.gradle @@ -0,0 +1,89 @@ +task sourcesJar(type: Jar) { + archiveClassifier.set('sources') + from android.sourceSets.main.java.srcDirs +} + +artifacts { + archives sourcesJar +} + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +ext { + PUBLISH_GROUP_ID = 'com.telefonica' + PUBLISH_ARTIFACT_ID = 'nestedscrollwebview' + PUBLISH_VERSION = version + + PUBLISH_RELEASE_NAME = 'Nested Scroll WebView for Android' + PUBLISH_DESCRIPTION = 'A webView implementation with nested scrolling support' + PUBLISH_REPO_URL = 'https://github.com/Telefonica/android-nested-scroll-webview' +} + +publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + artifact sourcesJar + + pom { + name = PUBLISH_RELEASE_NAME + description = PUBLISH_DESCRIPTION + url = PUBLISH_REPO_URL + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'android-team-telefonica' + name = 'Android Team' + email = 'cto-android@telefonica.com' + } + } + scm { + connection = 'scm:git:https://github.com/Telefonica/android-nested-scroll-webview.git' + developerConnection = 'scm:git:ssh://https://github.com/Telefonica/android-nested-scroll-webview.git' + url = 'https://github.com/Telefonica/android-nested-scroll-webview/tree/main' + } + withXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.getByName("implementation").allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + } + } + } + } + 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 { + def signingKeyId = findProperty("signingKeyId") + def signingKey = findProperty("signingKey") + def signingPassword = findProperty("signingPassword") + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) + sign publishing.publications +} diff --git a/nestedscrollwebview/build.gradle b/nestedscrollwebview/build.gradle index d76ebac..d6cf4a8 100644 --- a/nestedscrollwebview/build.gradle +++ b/nestedscrollwebview/build.gradle @@ -30,7 +30,6 @@ android { dependencies { implementation 'androidx.core:core-ktx:1.8.0' - implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'com.google.android.material:material:1.6.1' testImplementation 'junit:junit:4.13.2' From dd5a1b1678b6fbc02a979f6f0768894a0c21ae62 Mon Sep 17 00:00:00 2001 From: dpastor Date: Mon, 8 Aug 2022 17:49:41 +0200 Subject: [PATCH 2/2] ANDROID-10730 Complete workflows and publishing configuration --- .github/workflows/release.yml | 2 +- .github/workflows/snapshot.yml | 2 +- .github/workflows/tests.yml | 9 +------ README.md | 16 +++++++++++- build.gradle | 43 ++++++++++++++++++++++++++++++-- detekt.yml | 32 ++++++++++++++++++++++++ nestedscrollwebview/build.gradle | 2 ++ 7 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 detekt.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9b59adc..1a7a41f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ 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 }} + 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 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 57d51c9..dd7844a 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -22,4 +22,4 @@ 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 -DSNAPSHOT_VERSION=${{ github.event.inputs.snapshotVersion }} + run: "bash ./gradlew publishReleasePublicationToSonatypeRepository -DSNAPSHOT_VERSION=${{ github.event.inputs.snapshotVersion }}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 431372a..cc50186 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,13 +13,6 @@ jobs: distribution: 'temurin' java-version: '11' -# - name: Assemble -# run: ./gradlew assembleDebug -# - name: Lint -# run: ./gradlew lint -# - name: Unit Tests -# run: ./gradlew test - ## Build all our Build Types at once ## - name: Build all artifacts id: buildAllApks @@ -29,4 +22,4 @@ jobs: wrapper-cache-enabled: false dependencies-cache-enabled: false configuration-cache-enabled: false - arguments: assembleRelease check detekt \ No newline at end of file + arguments: assembleRelease check detekt diff --git a/README.md b/README.md index 7d6bcdb..39ae2dc 100644 --- a/README.md +++ b/README.md @@ -1 +1,15 @@ -# android-nested-scroll-webview \ No newline at end of file +

+ + + +

+ +# Android Nested Scroll WebView + +Android WebView implementation for nested scrolling layouts + +To include the library add to your app's `build.gradle`: + +```gradle +implementation 'com.telefonica:nestedscrollwebview:{version}' +``` diff --git a/build.gradle b/build.gradle index 8d85318..ead72f9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,49 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + dependencies { + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" + } +} + plugins { - id 'com.android.application' version '7.2.1' apply false - id 'com.android.library' version '7.2.1' apply false + 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' +} + +detekt { + input = files(rootProject.rootDir) + config = files("$projectDir/detekt.yml") + failFast = true + buildUponDefaultConfig = true + + reports { + html.enabled = true + xml.enabled = true + xml.destination = file("$buildDir/reports/detekt/detekt-checkstyle.xml") + html.destination = file("$buildDir/reports/detekt/detekt-report.html") + } } 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) { + version = System.getProperty("SNAPSHOT_VERSION")+"-SNAPSHOT" + } else { + version = System.getProperty("LIBRARY_VERSION") ?: "undefined" + } +} diff --git a/detekt.yml b/detekt.yml new file mode 100644 index 0000000..68965a5 --- /dev/null +++ b/detekt.yml @@ -0,0 +1,32 @@ +build: + maxIssues: 0 + weights: + complexity: 2 + formatting: 1 + LongParameterList: 1 + comments: 1 + +complexity: + TooManyFunctions: + active: false + LongMethod: + active: false + LongParameterList: + active: false + +empty-blocks: + EmptyFunctionBlock: + active: false +style: + MagicNumber: + active: false + NewLineAtEndOfFile: + active: false + UnusedPrivateMember: + active: false + WildcardImport: + active: false + +exceptions: + TooGenericExceptionThrown: + active: false diff --git a/nestedscrollwebview/build.gradle b/nestedscrollwebview/build.gradle index d6cf4a8..b0670f4 100644 --- a/nestedscrollwebview/build.gradle +++ b/nestedscrollwebview/build.gradle @@ -34,3 +34,5 @@ dependencies { testImplementation 'junit:junit:4.13.2' } + +apply from: "${rootProject.projectDir}/mavencentral.gradle"