Skip to content

Commit

Permalink
Merge pull request #2 from CharLEE-X/lint_and_publish
Browse files Browse the repository at this point in the history
Lint and publish
  • Loading branch information
charlee-dev authored Jul 9, 2023
2 parents 2adf474 + bef4be1 commit 55464da
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 225 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
- id: create
uses: nexus-actions/create-nexus-staging-repo@main
with:
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
username: ${{ secrets.OSSRH_USERNAME }}
password: ${{ secrets.OSSRH_PASSWORD }}
staging_profile_id: ${{ secrets.SONATYPE_PROFILE_ID }}
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }}

Expand All @@ -29,13 +29,13 @@ jobs:
java-version: 17
- name: Publish
run: |
./gradlew publishKotlinMultiplatformPublicationToSonatypeRepository
./gradlew publishAllPublicationsToSonatypeRepository
env:
SONATYPE_REPOSITORY_ID: ${{ needs.create_staging_repository.outputs.repository-id }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_PASSWORD: ${{ secrets.GPG_PRIVATE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.SIGNING_KEY }}
GPG_PRIVATE_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

finalize:
runs-on: ubuntu-latest
Expand All @@ -46,13 +46,13 @@ jobs:
if: ${{ needs.macos.result != 'success' }}
uses: nexus-actions/drop-nexus-staging-repo@main
with:
username: ${{ secrets.SONATYPE_USERNAME }}
username: ${{ secrets.OSSRH_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staged_repository_id: ${{ needs.create_staging_repository.outputs.repository-id }}
- name: Release
if: ${{ needs.macos.result == 'success' }}
uses: nexus-actions/release-nexus-staging-repo@main
with:
username: ${{ secrets.SONATYPE_USERNAME }}
username: ${{ secrets.OSSRH_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staged_repository_id: ${{ needs.create_staging_repository.outputs.repository-id }}
24 changes: 0 additions & 24 deletions .github/workflows/snapshot.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion buildSrc/src/main/kotlin/ProjectConfig.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2023 Adrian Witaszak - CharLEE-X. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.JavaVersion

/**
Expand All @@ -6,7 +10,7 @@ import org.gradle.api.JavaVersion

object ProjectConfig {
const val projectName = "NotifiKations"
const val groupId = "com.charleeex"
const val groupId = "com.charleex"
const val artifactId = "notifikations"
const val version = "0.0.1"
const val description = "Kotlin Multiplatform library (Android + iOS)"
Expand Down
35 changes: 35 additions & 0 deletions convention-plugins/src/main/kotlin/AppConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.gradle.api.JavaVersion

/*
* Copyright (c) 2023 Adrian Witaszak - CharLEE-X. Use of this source code is governed by the Apache 2.0 license.
*/

object AppConfig {
const val projectName = "NotifiKations"
const val groupId = "com.charleex"
const val artifactId = "notifikations"
const val version = "0.0.1"
const val description = "Kotlin Multiplatform library (Android + iOS)"
const val url = "https://github.com/CharLEE-X/notifiKations"

object Developer {
const val id = "charlee-dev"
const val name = "Adrian Witaszak"
const val email = "[email protected]"
}

object Licence {
const val name = "Apache 2.0 license"
const val url = "https://www.apache.org/licenses/LICENSE-2.0"
}

const val iosDevelopmentTarget = "14.1"

const val jvmTargetInt = 17
const val jvmTarget = jvmTargetInt.toString()

const val androidMinSdk = 26
const val androidCompileSdk = 33
const val androidTargetSdk = androidCompileSdk
val javaVersion = JavaVersion.VERSION_17
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ plugins {
id("org.jetbrains.dokka")
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.key"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Expand All @@ -28,9 +25,8 @@ if (secretPropsFile.exists()) {
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.key"] = System.getenv("SIGNING_KEY")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}
Expand All @@ -39,53 +35,62 @@ val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

fun getExtraString(name: String) = ext[name]?.toString()
val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(signingTasks)
}

publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
afterEvaluate {
publishing {
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}
}

// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())
publications.withType<MavenPublication> {
artifact(javadocJar.get())

// Provide artifacts information requited by Maven Central
pom {
name.set("MPP Sample library")
description.set("Sample Kotlin Multiplatform library (jvm + ios + js) test")
url.set("https://github.com/<your-github-repo>/mpp-sample-lib")
pom {
name.set(AppConfig.projectName)
description.set(AppConfig.description)
url.set(AppConfig.url)

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
licenses {
license {
name.set(AppConfig.Licence.name)
url.set(AppConfig.Licence.url)
}
}
}
developers {
developer {
id.set("charlee-dev")
name.set("Adrian Witaszak")
email.set("[email protected]")
developers {
developer {
id.set(AppConfig.Developer.id)
name.set(AppConfig.Developer.name)
email.set(AppConfig.Developer.email)
}
}
scm {
url.set(AppConfig.url)
}
}
scm {
url.set("https://github.com/<your-github-repo>/mpp-sample-lib")
}
}
}
}

// Signing artifacts. Signing.* extra properties values will be used
signing {
useInMemoryPgpKeys(
getExtraString("signing.key"),
getExtraString("signing.password")
)
sign(publishing.publications)
}

fun getExtraString(name: String): String = ext[name]?.toString()
?: findProperty(name)?.toString()
?: System.getenv(name)?.toString()
?: error("Property '$name' not found")
16 changes: 0 additions & 16 deletions local.properties

This file was deleted.

94 changes: 2 additions & 92 deletions notifications/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
// id("convention.publication")
id("org.jetbrains.dokka") version "1.8.20"
id("maven-publish")
id("signing")
id("convention.publication")
}

group = ProjectConfig.groupId + ".${ProjectConfig.artifactId}"
Expand All @@ -21,7 +18,7 @@ kotlin {
jvmToolchain(ProjectConfig.jvmTargetInt)

android {
publishLibraryVariants("release")
publishAllLibraryVariants()
}
ios {
binaries {
Expand Down Expand Up @@ -74,93 +71,6 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

tasks.check.dependsOn(tasks.detektAll)

val dokkaOutputDir = "$buildDir/dokka"

tasks.dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
}

val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}

val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}

publishing {
repositories {
maven {
name = "Sonatype"
setUrl {
val repositoryId =
System.getenv("SONATYPE_REPOSITORY_ID") ?: error("Missing env variable: SONATYPE_REPOSITORY_ID")
"https://oss.sonatype.org/service/local/staging/deployByRepositoryId/${repositoryId}/"
}
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
maven {
name = "Snapshot"
setUrl { "https://oss.sonatype.org/content/repositories/snapshots/" }
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}

publications {
withType<MavenPublication> {
artifact(javadocJar)
pom {
name.set(ProjectConfig.projectName)
description.set(ProjectConfig.description)
url.set(ProjectConfig.url)
licenses {
license {
name.set("MIT license")
url.set("https://opensource.org/licenses/MIT")
}
}
issueManagement {
system.set("Github")
url.set("https://github.com/CharLEE-X/notifiKations/issues")
}
scm {
connection.set("https://github.com/CharLEE-X/notifiKations.git")
url.set("")
}
developers {
developer {
name.set("Adrian Witaszak")
id.set("charlee-dev")
email.set("[email protected]")
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PRIVATE_PASSWORD")
)
sign(publishing.publications)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import co.touchlab.kermit.Logger
import com.charleeex.notifikations.R
import com.charleex.notifikations.R
import com.charleex.notifikations.NotificationService.Companion.COLLECTING_LOCATION_NOTIFICATION_ID
import com.charleex.notifikations.delegate.NotificationLocalPermissionDelegate
import com.charleex.notifikations.delegate.readNotificationStringOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.core.app.NotificationManagerCompat
import com.charleeex.notifikations.R
import com.charleex.notifikations.R
import com.charleex.notifikations.NotifiKations
import com.charleex.notifikations.model.NotificationSettings
import com.charleex.notifikations.model.PermissionState
Expand Down
Loading

0 comments on commit 55464da

Please sign in to comment.