This repository has been archived by the owner on Aug 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TIQR-211: make core library accessible on maven central
- Loading branch information
shachem
committed
Nov 10, 2021
1 parent
f9ff302
commit 17dce4b
Showing
4 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
@@ -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) | ||
|
@@ -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"]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters