Skip to content

Commit

Permalink
Add github action for publishing (#3)
Browse files Browse the repository at this point in the history
Also fix gradle wrapper
  • Loading branch information
sbihel authored Mar 6, 2024
1 parent e93c06a commit 39f4866
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 150 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: cd

on:
push:
tags:
- "*"


jobs:
validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate tag is valid
run: |
echo "${{ github.ref_name }}" | grep -P '^[0-9]+\.[0-9]+\.[0-9]+'
main:
runs-on: ubuntu-latest
needs: validation
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_KEY }}

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish package to GHCR
uses: gradle/gradle-build-action@v2
with:
arguments: publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
- name: Publish package to Central
uses: gradle/gradle-build-action@v2
with:
arguments: publishReleasePublicationToCentralPortal
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
VERSION: ${{ github.event.inputs.version }}
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

### AndroidStudio Patch ###

!/gradle/wrapper/gradle-wrapper.jar

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down Expand Up @@ -334,4 +330,8 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio
### AndroidStudio Patch ###

!gradle/wrapper/gradle-wrapper.jar

# End of https://www.gitignore.io/api/java,linux,macos,windows,android,intellij,androidstudio
78 changes: 64 additions & 14 deletions WalletSdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,78 @@ plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
`maven-publish`
}

tasks {
val sourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}
id("signing")
id("com.gradleup.nmcp")
}

publishing {
repositories {
maven {
url = uri("")
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/spruceid/wallet-sdk-rs")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}

publications {
// Creates a Maven publication called "release".
create<MavenPublication>("release") {
groupId = "com.spruceid.wallet.sdk"
artifactId = "walletsdk"
version = System.getenv("VERSION")

afterEvaluate {
groupId = "com.spruceid.wallet.sdk"
artifactId = "walletsdk"
version = "0.0.1"
artifact(tasks.getByName<Jar>("sourcesJar"))
from(components["release"])
}

pom {
packaging = "aar"
name.set("walletsdk")
description.set("Android SpruceID Wallet SDK")
url.set("https://github.com/spruceid/wallet-sdk-kt")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/license/mit/")
}
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Spruce Systems, Inc.")
email.set("[email protected]")
}
}
scm {
url.set(pom.url.get())
connection.set("scm:git:${url.get()}.git")
developerConnection.set("scm:git:${url.get()}.git")
}
}
}
}
}

signing {
useGpgCmd()
sign(publishing.publications["release"])
}

nmcp {
afterEvaluate {
publish("release") {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
publicationType = "AUTOMATIC"
}
}
}


android {
namespace = "com.spruceid.walletsdk"
Expand Down Expand Up @@ -58,6 +101,13 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

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

dependencies {
Expand All @@ -66,4 +116,4 @@ dependencies {
testImplementation("junit:junit:4.13.2")
androidTestImplementation("com.android.support.test:runner:1.0.2")
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
}
}
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.2" apply false
id("com.android.application") version "8.3.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
id("com.android.library") version "8.1.2" apply false
}
id("com.android.library") version "8.3.0" apply false
id("com.gradleup.nmcp") version "0.0.4" apply true
}
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.enableJetifier=true
android.enableJetifier=true

signing.gnupg.keyName=BD077076A67C38E1
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Thu Jan 25 11:00:12 BRT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 39f4866

Please sign in to comment.