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

feat: add a pipeline and an ability to publish #2

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Kotlin CI

on:
push:
pull_request:
branches:
- 'main'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Build project
run: ./gradlew build --no-daemon
- name: Test project
run: ./gradlew test --no-daemon

publish:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Set up GPG keys for signing
run: echo -n "${GPG_PRIVATE_KEY}" | base64 --decode > ${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Build project
run: ./gradlew build --no-daemon
- name: Publish to Sonatype
run: |
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository \
-Psigning.keyId=${GPG_KEY_ID} \
-Psigning.password=${GPG_PASSPHRASE} \
-Psigning.secretKeyRingFile=${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
91 changes: 77 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import java.time.Duration

plugins {
java
signing
id("maven-publish")

kotlin("jvm") version "1.9.24"
kotlin("plugin.serialization") version "1.9.24"
id("maven-publish")
}

val gradleScriptDir by extra("${rootProject.projectDir}/gradle")
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

buildscript {
repositories {
Expand All @@ -20,12 +24,29 @@ buildscript {
}
}

val gradleScriptDir by extra("${rootProject.projectDir}/gradle")

nexusPublishing {
connectTimeout.set(Duration.ofMinutes(7))
clientTimeout.set(Duration.ofMinutes(7))

transitionCheckOptions {
maxRetries.set(100)
delayBetween.set(Duration.ofSeconds(10))
}

repositories {
sonatype()
}
}

allprojects {
group = "io.qase"
version = "1.0.0"

repositories {
mavenCentral()
google()
mavenLocal()
}

Expand All @@ -36,8 +57,12 @@ allprojects {
}
}

configure(subprojects.filter { !it.name.contains("android") }
.filter { !it.name.contains("kaspresso") }) {
configure(
subprojects
.filter { !it.name.contains("android") }
.filter { !it.name.contains("kaspresso") }
) {
apply(plugin = "signing")
apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.kotlin.jvm")

Expand All @@ -47,10 +72,12 @@ configure(subprojects.filter { !it.name.contains("android") }

tasks.jar {
manifest {
attributes(mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
))
attributes(
mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
)
}
}

Expand All @@ -59,24 +86,60 @@ configure(subprojects.filter { !it.name.contains("android") }
archiveClassifier.set("sources")
}

val javadocJar by tasks.creating(Jar::class) {
from(tasks.getByName("javadoc"))
archiveClassifier.set("javadoc")
}

tasks.withType(Javadoc::class) {
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}

configure<JavaPluginConvention> {
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
create<MavenPublication>("maven") {
artifact(javadocJar)
artifact(sourceJar)
from(components["java"])

pom {
name.set(project.name)
description.set("Module ${project.name} of Qase Kotlin reporters.")
url.set("https://github.com/qase-tms/qase-kotlin")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("qase-tms")
name.set("Qase Team")
email.set("[email protected]")
}
}
scm {
developerConnection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
connection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
url.set("https://github.com/qase-tms/qase-kotlin")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/qase-tms/qase-kotlin/issue")
}
}
}
}
repositories {
mavenLocal()
}
}

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

Expand Down
52 changes: 42 additions & 10 deletions qase-kaspresso-reporter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
description = "Qase Kotlin Kaspresso reporter"

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

apply(plugin = "maven-publish")
Expand All @@ -14,7 +17,7 @@ repositories {

android {
namespace = "io.qase.kaspresso"
compileSdkVersion(30)
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -69,19 +72,48 @@ tasks.register<Jar>("androidSourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
}

publishing {
publications {
create<MavenPublication>("mavenAndroid") {
afterEvaluate {
afterEvaluate {
publishing {
publications {
create<MavenPublication>("maven") {
from(components["release"])
artifact(tasks.getByName<Jar>("androidJavadocsJar"))

pom {
name.set(project.name)
description.set("Module ${project.name} of Qase Kotlin reporters.")
url.set("https://github.com/qase-tms/qase-kotlin")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("qase-tms")
name.set("Qase Team")
email.set("[email protected]")
}
}
scm {
developerConnection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
connection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
url.set("https://github.com/qase-tms/qase-kotlin")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/qase-tms/qase-kotlin/issue")
}
}
}
groupId = "io.qase"
artifactId = "qase-kaspresso-reporter"
version = "1.0.0"

}
}
repositories {
mavenLocal()

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


62 changes: 47 additions & 15 deletions qase-kotlin-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
description = "Qase Kotlin Android Integration"

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

apply(plugin = "maven-publish")
Expand All @@ -14,7 +17,7 @@ repositories {

android {
namespace = "io.qase.commons.kotlin.android"
compileSdkVersion(30)
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -30,10 +33,8 @@ android {
}

dependencies {
implementation("androidx.test.ext:junit:1.1.2")
implementation("androidx.test:runner:1.4.0")
implementation("androidx.multidex:multidex:2.0.1")
implementation("androidx.test.uiautomator:uiautomator:2.2.0")
implementation("androidx.test.ext:junit:1.2.1")
implementation("androidx.test:runner:1.6.2")
implementation(project(":qase-kotlin-commons"))
}

Expand All @@ -54,7 +55,8 @@ tasks.register<Javadoc>("androidJavadocs") {
"http://docs.oracle.com/javase/7/docs/api/",
"http://developer.android.com/reference/",
"http://hc.apache.org/httpcomponents-client-5.0.x/httpclient5/apidocs/",
"http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/")
"http://hc.apache.org/httpcomponents-core-5.0.x/httpcore5/apidocs/"
)
}

tasks.register<Jar>("androidJavadocsJar") {
Expand All @@ -69,18 +71,48 @@ tasks.register<Jar>("androidSourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
}

publishing {
publications {
create<MavenPublication>("mavenAndroid") {
afterEvaluate {
afterEvaluate {
println(components.names)

publishing {
publications {
create<MavenPublication>("maven") {
from(components["release"])
artifact(tasks.getByName<Jar>("androidJavadocsJar"))

pom {
name.set(project.name)
description.set("Module ${project.name} of Qase Kotlin reporters.")
url.set("https://github.com/qase-tms/qase-kotlin")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("qase-tms")
name.set("Qase Team")
email.set("[email protected]")
}
}
scm {
developerConnection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
connection.set("scm:git:git://github.com/qase-tms/qase-kotlin")
url.set("https://github.com/qase-tms/qase-kotlin")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/qase-tms/qase-kotlin/issue")
}
}
}
groupId = "io.qase"
artifactId = "qase-kotlin-android"
version = "1.0.0"

}
}
repositories {
mavenLocal()

signing {
sign(publishing.publications["maven"])
}
}
Loading