Skip to content

Commit

Permalink
Update GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiu-udrea committed Dec 8, 2024
1 parent 46a327f commit 12282bf
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 117 deletions.
64 changes: 23 additions & 41 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

# gh secret set OSSRH_GPG_SECRET_KEY -a actions --body "$(gpg --export-secret-key --armor "<your key id>")"
# gh secret set OSSRH_GPG_SECRET_KEY_ID -a actions --body "<your key id>"
# gh secret set OSSRH_GPG_SECRET_KEY_PASSWORD -a actions --body "<your key password>"
# gh secret set OSSRH_PASSWORD -a actions --body "<your sonatype account password>"
# gh secret set OSSRH_USERNAME -a actions --body "<your sonatype account username>"
# gh secret set MAVEN_CENTRAL_USERNAME -a actions --body "<your maven central account username>"
# gh secret set MAVEN_CENTRAL_PASSWORD -a actions --body "<your maven central password>"
# gh secret set SIGNING_KEY -a actions --body "$(gpg --export-secret-keys --armor "<key id>" | grep -v '\-\-' | grep -v '^=.' | tr -d '\n')"
# gh secret set SIGNING_KEY_ID -a actions --body "<your key id>"
# gh secret set SIGNING_KEY_PASSWORD -a actions --body "<your key password>"

name: Deploy to central

Expand All @@ -23,47 +23,29 @@ jobs:
uses: ./.github/workflows/gradle.yml
deploy:
needs: build
strategy:
matrix:
include:
# - target: publishIosArm64PublicationToSonatypeRepository
# os: macos-latest
- target: publishAndroidReleasePublicationToSonatypeRepository
os: ubuntu-latest
- target: publishJvmPublicationToSonatypeRepository
os: ubuntu-latest
# - target: publishLinuxX64PublicationToSonatypeRepository
# os: ubuntu-latest
- target: publishKotlinMultiplatformPublicationToSonatypeRepository
os: ubuntu-latest
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
uses: gradle/actions/wrapper-validation@v3
# Needed only for Kotlin/Native
# - uses: actions/cache@v3
# with:
# path: |
# ~/.konan
# key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle publish
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: |
${{ matrix.target }}
closeSonatypeStagingRepository
-Psigning.gnupg.passphrase='${{secrets.OSSRH_GPG_SECRET_KEY_PASSWORD}}'
-Psigning.gnupg.keyName='${{secrets.OSSRH_GPG_SECRET_KEY_ID}}'
-PsonatypeUsername='${{secrets.OSSRH_USERNAME}}'
-PsonatypePassword='${{secrets.OSSRH_PASSWORD}}'
# Add `releaseSonatypeStagingRepository` here to release
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: ./gradlew publishToMavenCentral --no-configuration-cache
19 changes: 10 additions & 9 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
pull_request:
branches: [ "main" ]
workflow_call:
workflow_dispatch:

permissions:
contents: read
Expand All @@ -37,18 +38,18 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
uses: gradle/actions/wrapper-validation@v3
# - uses: actions/cache@v3
# with:
# path: |
# ~/.konan
# key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: ${{ matrix.target }}
run: ./gradlew ${{ matrix.target }}
3 changes: 1 addition & 2 deletions android-demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
>
<manifest>

</manifest>
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id("root.publication")
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
Expand Down
2 changes: 1 addition & 1 deletion convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
implementation(libs.nexus.publish)
implementation(libs.vanniktech.publish)
}
76 changes: 35 additions & 41 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`
import com.vanniktech.maven.publish.SonatypeHost

plugins {
`maven-publish`
signing
id("com.vanniktech.maven.publish")
}

publishing {
// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set(this@withType.name)
})
mavenPublishing {

// Provide artifacts information required by Maven Central
pom {
name.set("Model-View-Intent (MVI) components for Kotlin Multiplatform")
description.set("Minimalistic MVI implementation for Kotlin Multiplatform")
url.set("https://github.com/horatiu-udrea/mvi-kotlin")
coordinates(
groupId = "ro.horatiu-udrea",
artifactId = "mvi",
version = "0.1.0"
)
// Provide artifacts information required by Maven Central
pom {
name.set("Model-View-Intent (MVI) components for Kotlin Multiplatform")
description.set("Minimalistic MVI implementation for Kotlin Multiplatform")
inceptionYear.set("2024")
url.set("https://github.com/horatiu-udrea/mvi-kotlin")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("horatiu-udrea")
name.set("Horațiu Udrea")
email.set("[email protected]")
// organization.set("")
// organizationUrl.set("")
}
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
distribution.set("https://opensource.org/licenses/MIT")
}
scm {
url.set("https://github.com/horatiu-udrea/mvi-kotlin")
}
developers {
developer {
id.set("horatiu-udrea")
name.set("Horațiu Udrea")
email.set("[email protected]")
url.set("https://github.com/horatiu-udrea")
}
}
scm {
url.set("https://github.com/horatiu-udrea/mvi-kotlin")
}
}
}

signing {
if (project.hasProperty("signing.gnupg.keyName")) {
useGpgCmd()
sign(publishing.publications)
}
}
// Configure publishing to Sonatype
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

// Enable GPG signing for all publications
signAllPublications()
}
19 changes: 0 additions & 19 deletions convention-plugins/src/main/kotlin/root.publication.gradle.kts

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
agp = "8.5.2"
kotlin = "2.0.21"
nexus-publish = "2.0.0"
vanniktech-publish = "0.30.0"
android-minSdk = "24"
android-compileSdk = "34"
coroutines = "1.9.0"
Expand All @@ -13,7 +13,7 @@ dokka = "1.9.20"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }
vanniktech-publish = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin", version.ref = "vanniktech-publish" }
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
kotest-assertions = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
Expand Down
13 changes: 12 additions & 1 deletion mvi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaConfiguration.Visibility
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
Expand Down Expand Up @@ -59,4 +58,16 @@ tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
documentedVisibilities.set(setOf(Visibility.PUBLIC, Visibility.PROTECTED))
}
}

tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}

tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

0 comments on commit 12282bf

Please sign in to comment.