Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Zip artifacts
run: zip -r assemble.zip . -i '**/build/*.apk' '**/build/*.aab' '**/build/*.aar' '**/build/*.so'
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v7
with:
name: assemble
path: assemble.zip
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to Maven Central

on:
push:
tags:
- v*

jobs:
publish:
name: Publish release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Publish library to Maven Central
run: ./gradlew :library:publishAndReleaseToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
7 changes: 1 addition & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@ plugins {
id("com.android.application") version "8.1.1" apply false
id("com.android.library") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.7.0" apply false
}

task("clean") {
delete(rootProject.buildDir)
delete(project.buildDir)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:final-newline reported by reviewdog 🐶
File must end with a newline (\n)

99 changes: 74 additions & 25 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.android.library")
`maven-publish`
kotlin("android")
id("com.vanniktech.maven.publish") version "0.29.0"
}

val artifact = "crashhandler"
group = "com.dzeio"
val projectVersion = project.findProperty("version") as String? ?: "1.1.0"
version = projectVersion

publishing {
publications {
register<MavenPublication>("release") {
groupId = group as String?
artifactId = artifact
version = projectVersion

afterEvaluate {
from(components["release"])
}
// from: https://discuss.kotlinlang.org/t/use-git-hash-as-version-number-in-build-gradle-kts/19818/8
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected before expression body

.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply { waitFor(timeoutAmount, timeoutUnit) }
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
return@run ""
}
inputStream.bufferedReader().readText().trim()
}

val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir)
val tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir)
val commitId = "git rev-parse HEAD".runCommand(workingDir = rootDir)

val libGroup = "com.dzeio"
val libArtifact = "crashhandler"
val libVersion = System.getenv("version") ?: tag.drop(1).ifEmpty {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

project.findProperty("VERSION_NAME") as String? ?: "1.1.0"
}

android {
namespace = "$group.$artifact"
namespace = "$libGroup.$libArtifact"
compileSdk = 33
buildToolsVersion = "33.0.0"

Expand All @@ -37,20 +49,13 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
buildConfigField("String", "VERSION", "\"$projectVersion\"")
buildConfigField("String", "VERSION", "\"$libVersion\"")
}

testFixtures {
enable = true
}

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

buildTypes {
getByName("release") {
isMinifyEnabled = false
Expand All @@ -65,6 +70,7 @@ android {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = "11"
}
Expand All @@ -75,6 +81,49 @@ android {
}
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

signAllPublications()

coordinates(libGroup, libArtifact, libVersion)

pom {
name.set("Crash Handler")
description.set("An Android library that helps handling and reporting crashes gracefully.")
url.set("https://github.com/dzeiocom/crashhandler")
inceptionYear.set("2022")

licenses {
license {
name.set("MIT License")
url.set("https://github.com/dzeiocom/crashhandler/blob/master/LICENSE")
distribution.set("repo")
}
}

developers {
developer {
id.set("avior")
name.set("Avior")
email.set("contact@dze.io")
url.set("https://github.com/Aviortheking")
}
}

scm {
url.set("https://github.com/dzeiocom/crashhandler")
connection.set("scm:git:git://github.com/dzeiocom/crashhandler.git")
developerConnection.set("scm:git:ssh://git@github.com/dzeiocom/crashhandler.git")
}

issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/dzeiocom/crashhandler/issues")
}
}
}

dependencies {
// Necessary for the Activity (well to make it pretty :D)
implementation("com.google.android.material:material:1.8.0")
Expand Down
Loading