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 67fd04e
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 33 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
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

create-release:
runs-on: ubuntu-latest
needs:
- deploy-multiplatform
- deploy-jvm
- deploy-js
- deploy-ios-x64
- deploy-ios-arm64
- deploy-ios-simulator-arm64
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.
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)
}
43 changes: 29 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,39 @@
import com.vanniktech.maven.publish.SonatypeHost

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

group = "app.meetacy.ksm"
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

pom {
name = "calkt"
description = "Kotlin library that supports parsing and calculating various expressions"
url = "https://github.com/y9san9/calkt"

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")
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
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

calkt = "0.0.1"

Expand All @@ -11,3 +12,4 @@ 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 67fd04e

Please sign in to comment.