Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
asm0dey committed Jul 10, 2023
1 parent 8039809 commit 1413ab9
Show file tree
Hide file tree
Showing 21 changed files with 377 additions and 121 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# 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

name: Deploy to central

on: workflow_dispatch

permissions:
contents: read

jobs:
build:
uses: ./.github/workflows/gradle.yml
deploy:
needs: build
strategy:
matrix:
include:
- target: publishKotlinMultiplatformPublicationToSonatypeRepository
os: macos-latest
- target: publishIosArm64PublicationToSonatypeRepository
os: macos-latest
- target: publishIosSimulatorArm64PublicationToSonatypeRepository
os: macos-latest
- target: publishAndroidDebugPublicationToSonatypeRepository
os: ubuntu-latest
- target: publishAndroidReleasePublicationToSonatypeRepository
os: ubuntu-latest
- target: publishJvmPublicationToSonatypeRepository
os: ubuntu-latest
- target: publishLinuxX64PublicationToSonatypeRepository
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- 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 }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Gradle publish
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
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}}
52 changes: 52 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# 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

name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_call:

permissions:
contents: read

jobs:
build:
strategy:
matrix:
include:
- target: iosSimulatorArm64Test
os: macos-latest
- target: jvmTest
os: ubuntu-latest
- target: linuxX64Test
os: ubuntu-latest
- target: testDebugUnitTest
os: ubuntu-latest
- target: testReleaseUnitTest
os: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@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: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
with:
arguments: ${{ matrix.target }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/.idea/
/build/
/.gradle/
/convention-plugins/.gradle/
/convention-plugins/build/
.envrc
40 changes: 22 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
kotlin("multiplatform") version "1.8.22"
id("com.android.library") version "7.4.1"
kotlin("multiplatform") version "1.9.0"
id("com.android.library")
id("convention.publication")
}

group = "me.user"
version = "1.0-SNAPSHOT"
group = "com.github.asm0dey"
version = "0.0.1.2"

repositories {
google()
mavenCentral()
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -20,36 +25,35 @@ kotlin {
useJUnitPlatform()
}
}
android()
android {
publishLibraryVariants("release", "debug")
}
iosArm64 {
binaries {
framework {
baseName = "library"
}
}
}
iosSimulatorArm64() {
binaries {
framework {
baseName = "library"
}
}
}
linuxX64()
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val androidMain by getting
val androidUnitTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}
val iosArm64Main by getting
val iosArm64Test by getting
}
}

android {
namespace = "me.user.library"
namespace = "com.github.asm0dey.dummylib"
compileSdk = 33
defaultConfig {
minSdk = 24
Expand All @@ -60,4 +64,4 @@ android {
isMinifyEnabled = false
}
}
}
}
11 changes: 11 additions & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl` // Is needed to turn our build logic written in Kotlin into the Gradle Plugin
}

repositories {
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
}

dependencies {
implementation("io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin:2.0.0-rc-1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.signing

plugins {
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
}


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

nexusPublishing {
// Configure maven central repository
repositories {
sonatype()
}


// Configure all publications
}

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

// Provide artifacts information requited by Maven Central
pom {
name.set("Dummy Kotlin Multiplatform library")
description.set("Dummy library to test deployment to Maven Central")
url.set("https://github.com/asm0dey/dummylib-multiplatform")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("asm0dey")
name.set("Pasha Finkelshteyn")
email.set("asm0dey@jetbrains.com")
}
}
scm {
url.set("https://github.com/asm0dey/dummylib-multiplatform")
}
}
}
}

val gpgKeyId by extra { System.getenv("secrets.OSSRH_GPG_SECRET_KEY_ID") }
val gpgKey by extra { System.getenv("secrets.OSSRH_GPG_SECRET_KEY") }
val gpgKeyPassword by extra { System.getenv("secrets.OSSRH_GPG_SECRET_KEY_PASSWORD") }
signing {
useGpgCmd()
sign(publishing.publications)
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ kotlin.code.style=official
kotlin.mpp.androidSourceSetLayoutVersion=2
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096m
# Improves build time via enabling the gradle build cache
org.gradle.caching=true
org.gradle.configuration-cache=true

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 5 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -141,15 +144,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -194,10 +197,6 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Loading

0 comments on commit 1413ab9

Please sign in to comment.