From 9f98b094d96bda52abd4d62538f4b526fb43f20b Mon Sep 17 00:00:00 2001 From: conanoc Date: Wed, 21 Feb 2024 17:55:27 +0900 Subject: [PATCH] Setup for publishing to GitHub Packages (#19) Signed-off-by: conanoc --- README.md | 30 ++++++++++++++++-------------- app/build.gradle | 3 ++- ariesframework/build.gradle | 29 ++++++++++++++++++++++++++++- settings.gradle | 24 ++++++++++++++++++++++-- 4 files changed, 68 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 88169ca..c22840f 100644 --- a/README.md +++ b/README.md @@ -23,26 +23,28 @@ Aries Framework Kotlin supports most of [AIP 1.0](https://github.com/hyperledger ## Requirements & Installation -Aries Framework Kotlin requires Android 7.0+. It is not available on Maven Central yet. +Aries Framework Kotlin requires Android 7.0+. It is distributed as a Maven package hosted by GitHub Packages. -Clone this repo and add a dependency to your app's build.gradle file: +You can add a dependency to your app's build.gradle file: ```groovy dependencies { - implementation project('path_to_ariesframework') + implementation("org.hyperledger:aries-framework-kotlin:2.0.0") } ``` -You need additional dependencies if you include the framework as an AAR file: +You need to add the following to your project's build.gradle file to use GitHub Packages: ```groovy -dependencies { - implementation files('path_to_aar_file') - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0" - implementation 'org.slf4j:slf4j-api:1.7.32' - implementation 'ch.qos.logback:logback-classic:1.2.6' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.0' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.0' - implementation 'org.jetbrains.kotlinx:kotlinx-datetime:0.4.0' - implementation 'com.squareup.okhttp3:okhttp:4.10.0' +allprojects { + repositories { + maven { + setUrl("https://maven.pkg.github.com/hyperledger/aries-framework-kotlin") + credentials { + // You should put these in the local.properties file + username = "your github username" + password = "your github token for read:packages" + } + } + } } ``` @@ -74,7 +76,7 @@ To create an agent, first create a key to encrypt the wallet and save it in the val key = Agent.generateWalletKey() ``` -A genesis file for the indy pool should be included as a resource in the app bundle and should be copyed to the file system before initializing the agent. +A genesis file for the indy pool should be included as a resource in the app bundle and should be copied to the file system before initializing the agent. ```kotlin val genesisPath = "genesis.txn" val inputStream = applicationContext.assets.open(genesisPath) diff --git a/app/build.gradle b/app/build.gradle index 10f04c3..888745a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,8 @@ android { } dependencies { - implementation project(path: ':ariesframework') +// implementation project(path: ':ariesframework') + implementation("org.hyperledger:aries-framework-kotlin:2.0.0") implementation("org.hyperledger:anoncreds_uniffi:0.1.1-wrapper.1") implementation 'com.otaliastudios:cameraview:2.7.2' diff --git a/ariesframework/build.gradle b/ariesframework/build.gradle index 1f6ff36..0f6140f 100644 --- a/ariesframework/build.gradle +++ b/ariesframework/build.gradle @@ -68,14 +68,41 @@ dependencies { androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.0" } +ext["githubUsername"] = null +ext["githubToken"] = null + +def secretPropsFile = project.rootProject.file("local.properties") +if (secretPropsFile.exists()) { + Properties properties = new Properties() + secretPropsFile.withInputStream { properties.load(it) } + properties.each { k, v -> ext[k] = v } +} else { + ext["githubUsername"] = System.getenv("GITHUB_ACTOR") + ext["githubToken"] = System.getenv("GITHUB_TOKEN") +} + +def getExtraString(name) { + return ext[name] ?: "" +} + afterEvaluate { publishing { + repositories { + maven { + name = "github" + setUrl("https://maven.pkg.github.com/hyperledger/aries-framework-kotlin") + credentials { + username = getExtraString("githubUsername") + password = getExtraString("githubToken") + } + } + } publications { release(MavenPublication) { from components.release groupId 'org.hyperledger' artifactId 'aries-framework-kotlin' - version '1.0.0' + version '2.0.0' } } } diff --git a/settings.gradle b/settings.gradle index 49fa7cd..4e63cf2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,20 +5,40 @@ pluginManagement { gradlePluginPortal() } } + +ext["githubUsername"] = null +ext["githubToken"] = null + +def secretPropsFile = file("local.properties") +if (secretPropsFile.exists()) { + Properties properties = new Properties() + secretPropsFile.withInputStream { properties.load(it) } + properties.each { k, v -> ext[k] = v } +} else { + ext["githubUsername"] = System.getenv("GITHUB_ACTOR") + ext["githubToken"] = System.getenv("GITHUB_TOKEN") +} + +def getExtraString(name) { + return ext[name] ?: "" +} + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() + mavenLocal() mavenCentral() maven { setUrl("https://maven.pkg.github.com/hyperledger/aries-uniffi-wrappers") credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") + username = getExtraString("githubUsername") + password = getExtraString("githubToken") } } } } + rootProject.name = "aries-framework-kotlin" include ':app' include ':ariesframework'