diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml new file mode 100644 index 0000000..476e2ed --- /dev/null +++ b/.github/workflows/merge_request.yml @@ -0,0 +1,12 @@ +name: merge request + +on: + pull_request: + branches: + - 'master' + +jobs: + check: + uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.merge_request.yml@v1 + with: + java_version: '8' \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..115dce8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,11 @@ +name: publish + +on: + workflow_dispatch: + +jobs: + publish: + uses: tinkoff-mobile-tech/workflows/.github/workflows/android_lib.publish.yml@v1 + secrets: + gpg_key: ${{ secrets.GPG_KEY }} + sign_ossrh_gradle_properties: ${{ secrets.SIGN_OSSRH_GRADLE_PROPERTIES }} diff --git a/gradle.properties b/gradle.properties index 11ce787..5c90d2b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,7 @@ android.useAndroidX=true # 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 +android.useAndroidX=true VERSION_NAME=1.2.1 VERSION_CODE=11 diff --git a/gradle/publish-lib.gradle b/gradle/publish-lib.gradle index 4047929..dd9c17b 100755 --- a/gradle/publish-lib.gradle +++ b/gradle/publish-lib.gradle @@ -14,35 +14,36 @@ * limitations under the License. */ apply plugin: 'maven-publish' +apply plugin: 'signing' -def getEnvValueOrEmpty(String key) { - String value = System.getenv(key) - return value != null ? value : "" -} +def isAndroidLibrary = project.extensions.findByName('android') != null -def getReleaseRepository() { - return getEnvValueOrEmpty("PRIVATE_NEXUS_RELEASE_URL") +def getReleaseRepositoryUrl() { + return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL + : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" } -def getSnapshotRepository() { - return getEnvValueOrEmpty("PRIVATE_NEXUS_SNAPSHOT_URL") +def getSnapshotRepositoryUrl() { + return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL + : "https://oss.sonatype.org/content/repositories/snapshots/" } def getRepositoryUsername() { - return getEnvValueOrEmpty("PRIVATE_NEXUS_USER") + return hasProperty('ossrhUsername') ? ossrhUsername : '' } def getRepositoryPassword() { - return getEnvValueOrEmpty("PRIVATE_NEXUS_PASSWORD") + return hasProperty('ossrhPassword') ? ossrhPassword : '' } -afterEvaluate { project -> +afterEvaluate { publishing { publications { - mavenAar(MavenPublication) { - from components.release + release(MavenPublication) { + from isAndroidLibrary ? components.release : components.java groupId GROUP version versionName + artifactId POM_ARTIFACT_ID afterEvaluate { artifact sourcesJar artifact javadocJar @@ -73,10 +74,9 @@ afterEvaluate { project -> } } } - repositories { maven { - url isRelease ? getReleaseRepository() : getSnapshotRepository() + url isRelease ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl() credentials { username = getRepositoryUsername() password = getRepositoryPassword() @@ -107,4 +107,9 @@ afterEvaluate { project -> archiveClassifier.set('javadoc') from "$buildDir/docs/javadoc" } -} + + signing { + required { isRelease } + sign publishing.publications.release + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 21792eb..b1b5947 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip \ No newline at end of file