Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
TIQR-211: make core library accessible on maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
shachem committed Nov 10, 2021
1 parent f9ff302 commit 17dce4b
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_to_app_distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
id: short-sha
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.7'
ruby-version: '2.6'
- name: install firebase tool
run: |
yarn global add firebase-tools
Expand All @@ -39,4 +39,4 @@ jobs:
- name: Notify Slack about failure
run: |
curl -X POST -H 'Content-type: application/json' --data '{"icon_emoji": ":lock:", "username": "GitHub Actions", "text":":x: [Tiqr Android] Build #${{ github.run_number }} failed (${{ steps.short-sha.outputs.sha }})"}' ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
if: failure()
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish

on:
release:
# We'll run this workflow when a new GitHub release is created
types: [released]

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 8

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew :tiqr-client-android:assembleRelease

# Generates other artifacts
- name: Source jar
run: ./gradlew androidSourcesJar

# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishMavenAndroidPublicationToSonatypeRepository --max-workers 1
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
105 changes: 103 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import java.util.Properties

plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
id("androidx.navigation.safeargs.kotlin")
`maven-publish`
signing
}

android {
Expand Down Expand Up @@ -47,6 +51,17 @@ android {
jvmTarget = "1.8"
}
}
}

fun loadCustomProperties(file: File): java.util.Properties {
val properties = Properties()
if (file.isFile) {
properties.load(file.inputStream())
}
return properties
}

val secureProperties = loadCustomProperties(file("../local.properties"))

dependencies {
implementation(libs.kotlin.stdlib)
Expand Down Expand Up @@ -96,7 +111,93 @@ android {
androidTestImplementation(libs.androidx.testing.uiautomator)
androidTestImplementation(libs.kotlinx.coroutines.test)

androidTestImplementation(libs.dagger.hilt.testing)
kaptAndroidTest(libs.dagger.hilt.compiler)
androidTestImplementation(libs.dagger.hilt.testing)
kaptAndroidTest(libs.dagger.hilt.compiler)
}

group = "org.tiqr"
version = "0.0.7-SNAPSHOT"

tasks {
register("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}
}
publishing {
publications {
register<MavenPublication>("mavenAndroid") {
artifactId = "core"

afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
artifact(tasks.getByName("sourcesJar"))

pom {
name.set("core")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
description.set("refactoring original tiqr project")
developers {
developer {
name.set("sara hachem")
email.set("[email protected]")
}
developer {
name.set("Dmitry Kovalenko")
email.set("[email protected]")
}
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("https://github.com/SURFnet/tiqr-app-core-android.git")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
}

withXml {
fun groovy.util.Node.addDependency(dependency: Dependency, scope: String) {
appendNode("dependency").apply {
appendNode("groupId", dependency.group)
appendNode("artifactId", dependency.name)
appendNode("version", dependency.version)
appendNode("scope", scope)
}
}

asNode().appendNode("dependencies").let { dependencies ->
// List all "api" dependencies as "compile" dependencies
configurations.api.get().allDependencies.forEach {
dependencies.addDependency(it, "compile")
}
// List all "implementation" dependencies as "runtime" dependencies
configurations.implementation.get().allDependencies.forEach {
dependencies.addDependency(it, "runtime")
}
}
}
}
}
}

repositories {
maven {
name = "sonatype"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotRepo = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepoUrl)
credentials {
username = secureProperties.getProperty("USERNAME")
password =secureProperties.getProperty("PASSWORD")
}
}
}


signing {
useGpgCmd()
sign(publishing.publications["mavenAndroid"])
}
}
2 changes: 1 addition & 1 deletion data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ android {
androidTestImplementation(libs.androidx.testing.epsresso)
androidTestImplementation(libs.kotlinx.coroutines.test)
}
}
}

0 comments on commit 17dce4b

Please sign in to comment.