Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maven-publish instead of com.vanniktech.maven.publish #75

Merged
merged 12 commits into from
Jul 24, 2024
15 changes: 11 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7

- name: set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 #v4.2.1
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Setup Android SDK
uses: android-actions/setup-android@v3
uses: android-actions/setup-android@00854ea68c109d98c75d956347303bf7c45b0277 #v3.2.1

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
8 changes: 1 addition & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: Release
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout step
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -33,9 +33,3 @@ jobs:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publish

- name: Gradle Close and Release Repository
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew closeAndReleaseRepository
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ plugins {
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
id("com.android.library") version "8.5.1" apply false
id("com.google.dagger.hilt.android") version "2.51.1" apply false
id("com.vanniktech.maven.publish") version "0.29.0" apply false
}
122 changes: 73 additions & 49 deletions passwordless/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.vanniktech.maven.publish")
id("maven-publish")
id("signing")
}

android {
Expand Down Expand Up @@ -46,52 +44,11 @@ android {
jvmTarget = "1.8"
}

mavenPublishing {
coordinates("com.bitwarden", "passwordless-android", project.version.toString())
// publishToMavenCentral(SonatypeHost.DEFAULT)
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()

pom {
name.set("Passwordless Android Client SDK")
description.set("Passwordless Android Client SDK allows you to integrate Passwordless into your Android application.")
inceptionYear.set("2024")
url.set("https://www.github.com/bitwarden/passwordless-android/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("jonashendrickx")
name.set("Jonas Hendrickx")
organization.set("Bitwarden")
organizationUrl.set("https://github.com/bitwarden")
url.set("https://github.com/jonashendrickx")
}
}
scm {
url.set("https://github.com/bitwarden/passwordless-android")
connection.set("scm:git:[email protected]:passwordless/passwordless-android.git")
developerConnection.set("scm:git:[email protected]:bitwarden/passwordless-android.git")
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}

configure(
AndroidSingleVariantLibrary(
// the published variant
variant = "release",

// whether to publish a sources jar
sourcesJar = true,

// whether to publish a javadoc jar
publishJavadocJar = true,
)
)
}
}

Expand All @@ -114,3 +71,70 @@ dependencies {
androidTestImplementation(libs.espresso.core)
androidTestImplementation(libs.mockito.core)
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "com.bitwarden"
artifactId = "passwordless-android"
version = project.version.toString()

afterEvaluate {
from(components["release"])
}

pom {
name = "Passwordless Android Client SDK"
description = "Passwordless Android Client SDK allows you to integrate Passwordless into your Android application."
url = "https://www.github.com/bitwarden/passwordless-android/"
inceptionYear = "2024"

licenses {
license {
name = "GNU General Public License (GPL) v3.0"
url = "https://github.com/bitwarden/passwordless-android/blob/main/LICENSE_GPL.txt"
distribution = "https://github.com/bitwarden/passwordless-android/blob/main/LICENSE_GPL.txt"
}
}

developers {
developer {
id = "jonashendrickx"
name = "Jonas Hendrickx"
organization = "Bitwarden"
organizationUrl = "https://github.com/bitwarden"
url = "https://github.com/jonashendrickx"
}
}

scm {
url = "https://github.com/bitwarden/passwordless-android"
connection = "scm:git:[email protected]:bitwarden/passwordless-android.git"
developerConnection = "scm:git:[email protected]:bitwarden/passwordless-android.git"
}
}
}
}

repositories {
maven {
name = "S01"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl

credentials {
username = System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername") ?: throw Exception("'ORG_GRADLE_PROJECT_mavenCentralUsername' is missing.")
password = System.getenv("ORG_GRADLE_PROJECT_mavenCentralPassword") ?: throw Exception("'ORG_GRADLE_PROJECT_mavenCentralPassword' is missing.")
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("ORG_GRADLE_PROJECT_signingInMemoryKey"),
System.getenv("ORG_GRADLE_PROJECT_signingInMemoryKeyPassword")
)
sign(publishing.publications)
}