diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..629222b --- /dev/null +++ b/.github/workflows/publish.yml @@ -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/gradle-build-action@v2.4.2 + - 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/gradle-build-action@v2.4.2 + - 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/gradle-build-action@v2.4.2 + - 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/gradle-build-action@v2.4.2 + - 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/gradle-build-action@v2.4.2 + - 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/gradle-build-action@v2.4.2 + - 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 }} diff --git a/.gitignore b/.gitignore index 350fa12..6cb2d1e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ build .idea .kotlin .DS_Store -/gradle/wrapper/gradle-wrapper.jar diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..2cfffa7 --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 56c4856..374da92 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -4,4 +4,5 @@ plugins { dependencies { api(libs.kotlin.gradle.plugin) + api(libs.maven.publish.gradle.plugin) } diff --git a/build-logic/src/main/kotlin/publication-convention.gradle.kts b/build-logic/src/main/kotlin/publication-convention.gradle.kts index b6d92bc..01d288c 100644 --- a/build-logic/src/main/kotlin/publication-convention.gradle.kts +++ b/build-logic/src/main/kotlin/publication-convention.gradle.kts @@ -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 { - versionFromProperties { version -> - this.version = version + developers { + developer { + id = "y9san9" + name = "Alex Sokol" + email = "y9san9@gmail.com" + } + } + + 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() } diff --git a/build.gradle.kts b/build.gradle.kts index 4ed1456..f30f0c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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) -} \ No newline at end of file +version = libs.versions.calkt.get() diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 493c0bb..fef854a 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -2,6 +2,8 @@ plugins { id("kmp-library-convention") } +version = libs.versions.calkt.get() + dependencies { commonMainImplementation(libs.bignum) commonTestImplementation(projects.math) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1d4e60a..d9da069 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,7 @@ kotlin = "2.0.0" bignum = "0.3.10" +maven-publish = "0.29.0" calkt = "0.0.1" @@ -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" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/math/build.gradle.kts b/math/build.gradle.kts index c82d3ef..f73cfa5 100644 --- a/math/build.gradle.kts +++ b/math/build.gradle.kts @@ -2,6 +2,8 @@ plugins { id("kmp-library-convention") } +version = libs.versions.calkt.get() + dependencies { commonMainApi(projects.core) } diff --git a/units/build.gradle.kts b/units/build.gradle.kts index bd4ba2c..e99fb04 100644 --- a/units/build.gradle.kts +++ b/units/build.gradle.kts @@ -2,6 +2,8 @@ plugins { id("kmp-library-convention") } +version = libs.versions.calkt.get() + dependencies { commonMainApi(projects.math) }