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 af94f26
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 6 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:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_KEY: ${{ secrets.OSSRH_KEY }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.GPG_KEY_CONTENTS }}

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 printSdkVersion -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 printSdkVersion -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 printSdkVersion -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 printSdkVersion -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 printSdkVersion -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 printSdkVersion -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 }}
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.
61 changes: 55 additions & 6 deletions build-logic/src/main/kotlin/publication-convention.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import java.util.*

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

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

publishing {
repositories {
maven {
name = "GitHub"
url = uri("https://maven.pkg.github.com/meetacy/ksm")
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
name = "MavenCentral"

credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
username = System.getenv("OSSRH_USER")
password = System.getenv("OSSRH_KEY")
}
}
}
Expand All @@ -20,5 +22,52 @@ publishing {
versionFromProperties { version ->
this.version = version
}
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"
}
}

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"
}
}
}
}

val signingKeyId: String? = System.getenv("SIGNING_KEY_ID")
if (signingKeyId != null) {
apply(plugin = "signing")

configure<SigningExtension> {
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")
val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key ->
String(Base64.getDecoder().decode(base64Key))
}

useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}

val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(signingTasks)
}
}

0 comments on commit af94f26

Please sign in to comment.