Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
asm0dey committed Jul 11, 2023
0 parents commit f009bc2
Show file tree
Hide file tree
Showing 29 changed files with 710 additions and 0 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@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}}
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@ce999babab2de1c4b649dc15f0ee67e6246c994f
with:
arguments: ${{ matrix.target }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea/
/build/
/.gradle/
/convention-plugins/.gradle/
/convention-plugins/build/
.envrc
67 changes: 67 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

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

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"
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
android {
publishLibraryVariants("release", "debug")
}
iosArm64 {
binaries {
framework {
baseName = "library"
}
}
}
iosSimulatorArm64() {
binaries {
framework {
baseName = "library"
}
}
}
linuxX64()
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}

android {
namespace = "com.github.asm0dey.dummylib"
compileSdk = 33
defaultConfig {
minSdk = 24
targetSdk = 33
}
buildTypes {
getByName("release") {
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("[email protected]")
}
}
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)
}
8 changes: 8 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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 added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit f009bc2

Please sign in to comment.