Skip to content

Commit

Permalink
ci: Setup OSS publishing and signing artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
warnyul committed Apr 18, 2024
1 parent 1162f45 commit be9c9b5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Build with Gradle Wrapper
run: ./gradlew build koverXmlReport publishToMavenLocal
run: ./gradlew build koverXmlReport publish
env:
JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME }}'
JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD }}'
- name: Upload coverage report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ hashFiles('build/reports/kover/report.xml') != '' }}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group = 'tech.apter.junit5.jupiter'
version = property('apter.junit5.robolectric.extension.version')
version = property('tech.apter.junit5.robolectric.extension.version')
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
android.useAndroidX=true
kotlin.code.style=official
apter.junit5.robolectric.extension.version=0.1.0-SNAPSHOT
tech.apter.junit5.robolectric.extension.version=0.1.0-SNAPSHOT
33 changes: 24 additions & 9 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

tasks.register('dokkaJavadocJar', Jar) {
dependsOn dokkaJavadoc
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -44,8 +50,8 @@ publishing {
repositories {
maven {
name = 'MavenCentral'
final releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
final snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
final releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2'
final snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots'
url = version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME')
Expand All @@ -55,10 +61,19 @@ publishing {
}
}

//signing {
// useInMemoryPgpKeys(
// System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_PGP_SIGNING_KEY'),
// System.getenv('JUNIT5_ROBOLECTRIC_EXTENSION_PGP_SIGNING_PASSWORD'),
// )
// sign(publishing.publications["mavenJava"])
//}
final JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY = System.getenv(
'JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY'
) ?: ""
final JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD = System.getenv(
'JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD'
) ?: ""

if (!JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY.isEmpty() && !JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD.isEmpty()) {
signing {
useInMemoryPgpKeys(
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY,
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD,
)
sign(publishing.publications["mavenJava"])
}
}
6 changes: 0 additions & 6 deletions robolectric-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ dependencies {
testRuntimeOnly(libs.junit5JupiterEngine)
}

tasks.register('dokkaJavadocJar', Jar) {
dependsOn dokkaJavadoc
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
}

private void bashExecute(String command) {
final process = command.execute()
final error = process.errorReader().readLines().join("\n")
Expand Down

0 comments on commit be9c9b5

Please sign in to comment.