Skip to content

Commit

Permalink
Merge pull request #42 from algorandfoundation/chore/publish-to-maven…
Browse files Browse the repository at this point in the history
…-central

ci: publish to maven central
  • Loading branch information
HashMapsData2Value authored Oct 22, 2024
2 parents c8ac0f3 + 8dd1053 commit adca4f9
Show file tree
Hide file tree
Showing 19 changed files with 433 additions and 157 deletions.
53 changes: 50 additions & 3 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,36 @@ name: Generate Release
on:
push:
branches:
- "release/*"
- "main"
- main
- release/1.x
workflow_dispatch:

concurrency: release

permissions:
contents: write
issues: write
checks: write

jobs:
generate-release:
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
packages: write
pull-requests: write
id-token: write
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}

- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}

- name: Set up JDK 21
uses: actions/setup-java@v4
Expand All @@ -24,6 +46,9 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Initialize submodule, generate jars, and build (including tests)
run: chmod +x initialize.sh && ./initialize.sh

- name: Setup Node
uses: actions/setup-node@v4
with:
Expand All @@ -35,4 +60,26 @@ jobs:
- name: Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Prepare files
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publish

- name: Publish to Maven Central
if: github.ref == 'refs/heads/release/1.x'
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew publishToMavenCentralPortal

- name: Merge Release -> Trunk
uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f
if: github.ref == 'refs/heads/release/1.x'
with:
type: now
from_branch: release/1.x
target_branch: main
github_token: ${{ steps.app-token.outputs.token }}
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,36 @@ Currently there are two folders, one to create an .aar file for use in Android,
| Android | 26 |
| Java | 17 |

## Installation
## Installation - How to Incorporate Into Your Project

### Android

Add the following to your build.gradle.kts:

```kotlin
implementation("net.java.dev.jna:jna:5.14.0@aar")
implementation("foundation.algorand.xhdwalletapi:xhdwalletapi-android:{VERSION}")
```

JNA is necessary for the app to understand the path to the LibSodium binaries.

### Java

```kotlin
implementation("foundation.algorand.xhdwalletapi:xhdwalletapi:{VERSION}")
```

### BIP39

You might find it helpful to use a BIP39 library. Include one like so:

```kotlin
implementation("cash.z.ecc.android:kotlin-bip39:1.0.7")
```

The examples below use that library.

## Setup (local development)

This library uses a forked version of LazySodium-Java that exposes Ed25519 operations. The fork has been added as a Git Submodule. It needs to be initialized, built and have its .jar files moved into lib/libs at the root level of this repository.

Expand Down Expand Up @@ -49,7 +78,7 @@ This project follows [Semantic Versioning](https://semver.org) guidelines and us

To create a new release, merge off of `main` into the release branch, e.g. `release/1.x`. `semantic-release` will run, calculate the next version number based off of the commits, create a corresponding tag and produce a release. The release notes will have been populated from the older commits.

Afterwards, merge the branch back into `main`. `gradle.properties` which contains the version read by androidModule, jvmModule and sharedModule will have also been updated by `semantic-release`, ensuring the repository release version on GitHub is in-sync with the versions for the respective modules.
Afterwards, merge the branch back into `main`. `gradle.properties` which contains the version read by XHDWalletAPI-Android, XHDWalletAPI-JVM and sharedModule will have also been updated by `semantic-release`, ensuring the repository release version on GitHub is in-sync with the versions for the respective modules.

## How to Use

Expand Down
154 changes: 154 additions & 0 deletions XHDWalletAPI-Android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
version = project.property('version')
group = "foundation.algorand.xhdwalletapi"

buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "tech.yanand.maven-central-publish:tech.yanand.maven-central-publish.gradle.plugin:1.2.0"
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'tech.yanand.maven-central-publish'


android {
compileSdkVersion 34
buildToolsVersion "33.0.3"

buildFeatures {
viewBinding = true
}

defaultConfig {
archivesBaseName = "XHDWalletAPI-Android"
namespace "foundation.algorand.xhdwalletapi"
minSdkVersion 26
targetSdkVersion 34
versionCode 16
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

lintOptions {
baseline file("lint-baseline.xml")
}

sourceSets {
main {
java.srcDirs = ['../sharedModule/src/main/kotlin']
jni.srcDirs = []
jniLibs.srcDirs = ['src/main/jniLibs']
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}
}

dependencies {
api project(':sharedModule')
api fileTree(dir: '../sharedModule/libs', include: '*.jar')
}

task copyAarToRoot(type: Copy) {
dependsOn assemble

from "$buildDir/outputs/aar"
into "$rootDir/build"
include "*.aar"
}

build.finalizedBy(copyAarToRoot)

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

publishing {
publications {
mavenAndroid(MavenPublication) {
groupId = project.group
artifactId = "xhdwalletapi-android"
version = project.version

artifact("$buildDir/outputs/aar/${archivesBaseName}-release.aar") {
classifier = null
}
artifact(sourcesJar)

pom {
name.set("XHDWalletAPI-Android")
description.set("A library for extended hierarchical deterministic wallets for Android")
url.set("https://github.com/HashMapsData2Value/hmd2v-fork-xHD-Wallet-API-kt")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("AlgrandFoundation")
name.set("Algorand Foundation")
email.set("[email protected]")
}
}

scm {
connection.set("scm:git:git://github.com/AlgorandFoundation/xHD-Wallet-API-kt.git")
developerConnection.set("scm:git:ssh://github.com/AlgorandFoundation/xHD-Wallet-API-kt.git")
url.set("https://github.com/AlgorandFoundation/xHD-Wallet-API-kt.git")
}
}
}
}

repositories {
maven {
name = "Local"
url = uri(layout.buildDirectory.dir("repos/bundles_android").get().asFile.toURI())
}
}
}

signing {
def signingKey = System.getenv("GPG_PRIVATE_KEY") ?: ""
def signingPassword = System.getenv("GPG_PASSPHRASE") ?: ""
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["mavenAndroid"])
}

def username = System.getenv("OSSRH_USERNAME") ?: ""
def password = System.getenv("OSSRH_PASSWORD") ?: ""

mavenCentral {
repoDir = layout.buildDirectory.dir("repos/bundles_android")
// Token for Publisher API calls obtained from Sonatype official,
// it should be Base64 encoded of "username:password".
authToken = Base64.getEncoder().encodeToString("$username:$password".getBytes())
// Whether the upload should be automatically published or not. Use 'USER_MANAGED' if you wish to do this manually.
// This property is optional and defaults to 'AUTOMATIC'.
publishingType = "AUTOMATIC"
// Max wait time for status API to get 'PUBLISHING' or 'PUBLISHED' status when the publishing type is 'AUTOMATIC',
// or additionally 'VALIDATED' when the publishing type is 'USER_MANAGED'.
// This property is optional and defaults to 60 seconds.
maxWait = 500
}
File renamed without changes.
Loading

0 comments on commit adca4f9

Please sign in to comment.