Skip to content

Commit

Permalink
Prepare to publish to OSSRH (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave authored Dec 1, 2023
1 parent a7b1b4b commit c0eeeba
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
java-version: "17"
check-latest: false
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.4.2
with:
dependency-graph: generate-and-submit
- name: Setup Rust
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: publish

on:
# For convenience, run upon tagging a release.
release:
types:
- published
# This is mainly intended for snapshots.
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: "17"
check-latest: false
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.4.2
- name: Setup Rust
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
- name: Rust caching
uses: Swatinem/rust-cache@v2
with:
key: ${{ steps.rust-toolchain.outputs.cachekey }}
workspaces: divviup/rust
- name: Upload artifacts
env:
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_SIGNING_PASSPHRASE }}
run: ./gradlew :divviup:publishReleasePublicationToOSSRHRepository
34 changes: 34 additions & 0 deletions divviup/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("com.android.library")
id("org.mozilla.rust-android-gradle.rust-android")
id("maven-publish")
signing
}

android {
Expand Down Expand Up @@ -127,4 +128,37 @@ publishing {
}
}
}

repositories {
maven {
name = "OSSRH"

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

authentication {
register<BasicAuthentication>("basic")
}

credentials {
val ossrhUsername: String? by project
val ossrhPassword: String? by project
username = ossrhUsername
password = ossrhPassword
}
}
}
}

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

val signingKey: String? by project
val signingPassword: String? by project
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
} else {
useGpgCmd()
}
}

0 comments on commit c0eeeba

Please sign in to comment.