Skip to content

Commit

Permalink
feat: Added job to publish to maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Aug 17, 2024
1 parent bd43e44 commit 607cb65
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 50 deletions.
153 changes: 153 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Library Release Deploy

on:
push:
branches: [ "main" ]
workflow_dispatch:

env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY_CONTENTS }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}

jobs:

deploy-multiplatform:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.output_version.outputs.release_version }}
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishKotlinMultiplatformPublicationToMavenCentralRepository
- name: Add Sdk Version to Output
id: output_version
run: echo "release_version=${{ env.release_version }}" >> $GITHUB_OUTPUT

deploy-jvm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishJvmPublicationToMavenCentralRepository

deploy-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishJsPublicationToMavenCentralRepository

deploy-ios-x64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Konan Cache Setup
uses: actions/cache@v3
with:
path: ~/.konan
key: konan-cache
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishIosX64PublicationToMavenCentralRepository

deploy-ios-arm64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Konan Cache Setup
uses: actions/cache@v3
with:
path: ~/.konan
key: konan-cache
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishIosArm64PublicationToMavenCentralRepository

deploy-ios-simulator-arm64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Konan Cache Setup
uses: actions/cache@v3
with:
path: ~/.konan
key: konan-cache
- name: Gradle Sync
run: ./gradlew
- name: Add Sdk Version to Env
run: |
release_version=$(./gradlew printVersion -q)
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Publish ${{ env.release_version }}
run: ./gradlew publishIosSimulatorArm64PublicationToMavenCentralRepository

publish-release:
runs-on: ubuntu-latest
needs:
- deploy-multiplatform
- deploy-jvm
- deploy-js
- deploy-ios-x64
- deploy-ios-arm64
- deploy-ios-simulator-arm64
steps:
- uses: actions/checkout@v3
- name: Gradle Cache Setup
uses: gradle/[email protected]
- name: Run Gradle Task
run: ./gradlew publishToMavenCentral

create-release:
runs-on: ubuntu-latest
needs:
- deploy-multiplatform
- publish-release
steps:
- name: Create Release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.deploy-multiplatform.outputs.release_version }}
release_name: Release ${{ needs.deploy-multiplatform.outputs.release_version }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ build
.idea
.kotlin
.DS_Store
/gradle/wrapper/gradle-wrapper.jar
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Alex Sokol

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,13 @@ Parsed as: (((1 Kilometers) minus (0.5 Miles)) plus (2 Yards)).convert(Inches)
Result: 7886.272 Inches
```

## Implementation
## Dependency

Work In Progress. Will be available at maven central soon.
Now you can use workarounds like [jitpack.io](https://jitpack.io/#y9san9/calkt/-SNAPSHOT):
You can get latest version from `Releases` tab on GitHub.

Add Jitpack repo in the root build.gradle at the end of repositories:

```kotlin
dependencyResolutionManagement {
repositories {
mavenCentral()
maven("https://jitpack.io")
}
}
```

Step 2. Add the dependency
```kotlin
dependencies {
implementation("com.github.y9san9:calkt:-SNAPSHOT")
implementation("com.github.y9san9:calkt:$version")
}
```

Expand Down
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ plugins {

dependencies {
api(libs.kotlin.gradle.plugin)
api(libs.maven.publish.gradle.plugin)
}
45 changes: 31 additions & 14 deletions build-logic/src/main/kotlin/publication-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("org.gradle.maven-publish")
id("com.vanniktech.maven.publish")
}

group = "app.meetacy.ksm"
group = "me.y9san9.calkt"

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

publishing {
repositories {
maven {
name = "GitHub"
url = uri("https://maven.pkg.github.com/meetacy/ksm")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
pom {
name = "calkt"
description = "Kotlin library that supports parsing and calculating various expressions"
url = "https://github.com/y9san9/calkt"

licenses {
license {
name = "MIT"
distribution = "repo"
url = "https://github.com/y9san9/calkt/blob/main/LICENSE.md"
}
}
}

publications.withType<MavenPublication> {
versionFromProperties { version ->
this.version = version
developers {
developer {
id = "y9san9"
name = "Alex Sokol"
email = "[email protected]"
}
}

scm {
connection ="scm:git:ssh://github.com/y9san9/calkt.git"
developerConnection = "scm:git:ssh://github.com/y9san9/calkt.git"
url = "https://github.com/y9san9/calkt"
}
}

signAllPublications()
}
20 changes: 2 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
plugins {
kotlin("jvm") version "2.0.0"
id("print-version-convention")
}

group = "me.y9san9"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
testImplementation(kotlin("test"))
}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
version = libs.versions.calkt.get()
2 changes: 2 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id("kmp-library-convention")
}

version = libs.versions.calkt.get()

dependencies {
commonMainImplementation(libs.bignum)
commonTestImplementation(projects.math)
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

kotlin = "2.0.0"
bignum = "0.3.10"
maven-publish = "0.29.0"

calkt = "0.0.1"
calkt = "0.0.2"

[libraries]

bignum = { module = "com.ionspin.kotlin:bignum", version.ref = "bignum" }

# gradle plugins
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
maven-publish-gradle-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions math/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id("kmp-library-convention")
}

version = libs.versions.calkt.get()

dependencies {
commonMainApi(projects.core)
}
2 changes: 2 additions & 0 deletions units/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id("kmp-library-convention")
}

version = libs.versions.calkt.get()

dependencies {
commonMainApi(projects.math)
}

0 comments on commit 607cb65

Please sign in to comment.