Skip to content

Commit

Permalink
Create OSSHR Package (#32)
Browse files Browse the repository at this point in the history
* add api client with grpc kotlin

* first pass at package work

* add a release script

* first pass at package management

* move signing in to after
  • Loading branch information
nplasterer authored Feb 23, 2023
1 parent b26d97b commit d2ddf72
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Gradle Run ktlint
run: ./gradlew ktlintCheck --continue
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release XMTP Android Package
on:
push:
branches:
- release

jobs:
library:
name: Release Library
runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Run build with Gradle Wrapper
run: ./gradlew build
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_version }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Gradle Publish
env:
RELEASE_VERSION: ${{ steps.tag_version.outputs.new_version }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGN_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
SIGN_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
MAVEN_PROFILE_ID: ${{ secrets.MAVEN_PROFILE_ID }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,19 @@ plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'io.github.gradle-nexus.publish-plugin' version "1.2.0"
}

group = "org.xmtp"
version = System.getenv("RELEASE_VERSION")

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
stagingProfileId = System.getenv("MAVEN_PROFILE_ID")
}
}
}
54 changes: 54 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
id 'signing'
id 'maven-publish'
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'com.google.protobuf' version '0.9.1'
Expand Down Expand Up @@ -33,6 +35,13 @@ android {
kotlinOptions {
jvmTarget = '11'
}

publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

protobuf {
Expand Down Expand Up @@ -73,4 +82,49 @@ dependencies {
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId = "org.xmtp"
artifactId = "android"
version = System.getenv("RELEASE_VERSION")
from components.release

pom {
name = "XMTP"
description = "XMTP Android Library"
url = "https://github.com/xmtp/xmtp-android"
packaging = "jar"

licenses {
license {
name = "MIT License"
url = "https://github.com/xmtp/xmtp-android/blob/main/LICENSE"
}
}
developers {
developer {
id = "xmtp"
name = "xmtp"
email = "[email protected]"
}
}
scm {
connection = "https://github.com/xmtp/xmtp-android.git"
developerConnection = "https://github.com/xmtp/xmtp-android.git"
url = "https://github.com/xmtp/xmtp-android/tree/main"
}
}
}
}
}
signing {
def signingKey = System.getenv("SIGN_KEY")
def signingPassword = System.getenv("SIGN_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.release
}
}
16 changes: 16 additions & 0 deletions script/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/python
import os
import subprocess

if (input("\nAre you sure? This will replace the current \"release\" branch with origin/main. Y/n\n") != "Y"):
print(u'\U0001f44C' + " lmk if you change your mind")
exit(0)

os.system("git fetch origin")
os.system("git checkout release")

os.system("git reset --hard origin/main")
os.system("git push --force origin release")

print(u'\U0001f680' + " Successfully pushed origin/main to release")
print(u'\U0001f440' + " Follow the deploy at https://github.com/xmtp/xmtp-android/actions")

0 comments on commit d2ddf72

Please sign in to comment.