Skip to content

Commit

Permalink
Merge pull request #38 from Tinkoff/add_workflow
Browse files Browse the repository at this point in the history
Add workflow
  • Loading branch information
Nov1kov authored Feb 22, 2022
2 parents 2e16fd9 + 8445324 commit fddd00d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 17 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/merge_request.yml
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 11 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 21 additions & 16 deletions gradle/publish-lib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,10 +74,9 @@ afterEvaluate { project ->
}
}
}

repositories {
maven {
url isRelease ? getReleaseRepository() : getSnapshotRepository()
url isRelease ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
Expand Down Expand Up @@ -107,4 +107,9 @@ afterEvaluate { project ->
archiveClassifier.set('javadoc')
from "$buildDir/docs/javadoc"
}
}

signing {
required { isRelease }
sign publishing.publications.release
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fddd00d

Please sign in to comment.