diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..bdf835d --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,38 @@ +name: Gradle Publish Release + +on: + release: + types: + - created + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'corretto' + + - name: Cache Gradle dependencies + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + + - name: Set Gradle executable permissions + run: chmod +x ./gradlew + + - name: Build and Publish + env: + LIB_VERSION: ${{ github.ref_name }} + SSH_DEPLOY_PATH: ${{ secrets.SSH_DEPLOY_PATH }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} + SSH_USER: ${{ secrets.SSH_USER }} + run: ./gradlew publish diff --git a/build-conventions/build.gradle.kts b/build-conventions/build.gradle.kts index b25e062..c56f7fe 100644 --- a/build-conventions/build.gradle.kts +++ b/build-conventions/build.gradle.kts @@ -15,4 +15,5 @@ kotlin { dependencies { api(libs.kotlin.plugin) api(libs.android.plugin) + api(libs.vanniktech.maven.publish) } \ No newline at end of file diff --git a/build-conventions/src/main/kotlin/jvm-convention.gradle.kts b/build-conventions/src/main/kotlin/jvm-convention.gradle.kts index cb8f9fa..522fb93 100644 --- a/build-conventions/src/main/kotlin/jvm-convention.gradle.kts +++ b/build-conventions/src/main/kotlin/jvm-convention.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.kotlin.gradle.dsl.* - plugins { kotlin("jvm") } diff --git a/build-conventions/src/main/kotlin/multiplatform-library-convention.gradle.kts b/build-conventions/src/main/kotlin/multiplatform-library-convention.gradle.kts index e4c78f2..9547eea 100644 --- a/build-conventions/src/main/kotlin/multiplatform-library-convention.gradle.kts +++ b/build-conventions/src/main/kotlin/multiplatform-library-convention.gradle.kts @@ -2,8 +2,66 @@ import org.jetbrains.kotlin.gradle.dsl.* plugins { id("multiplatform-convention") + id("com.vanniktech.maven.publish") } kotlin { explicitApi = ExplicitApiMode.Strict +} + +mavenPublishing { + pom { + url.set("https://github.com/timemates/credentials-storage-kt") + inceptionYear.set("2023") + + licenses { + license { + name.set("The MIT License") + url.set("https://opensource.org/licenses/MIT") + distribution.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("kotleni") + name.set("Viktor Varenik") + url.set("https://github.com/kotleni") + } + + developer { + id.set("y9vad9") + name.set("Vadym Yaroshchuk") + url.set("https://github.com/y9vad9/") + } + } + + scm { + url.set("https://github.com/timemates/credentials-storage-kt") + connection.set("scm:git:git://github.com/timemates/credentials-storage-kt.git") + developerConnection.set("scm:git:ssh://git@github.com/timemates/credentials-storage-kt.git") + } + + issueManagement { + system.set("GitHub Issues") + url.set("https://github.com/timemates/credentials-storage-kt/issues") + } + } +} + +publishing { + repositories { + maven { + name = "TimeMates" + + url = uri( + "sftp://${System.getenv("SSH_HOST")}:22/${System.getenv("SSH_DEPLOY_PATH")}" + ) + + credentials { + username = System.getenv("SSH_USER") + password = System.getenv("SSH_PASSWORD") + } + } + } } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 45846e6..a3506a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,6 @@ plugins { } group = "com.timemates.credentials" -version = "1.0-SNAPSHOT" kotlin { sourceSets { @@ -59,4 +58,17 @@ android { isIncludeAndroidResources = true } } +} + +mavenPublishing { + coordinates( + groupId = "io.timemates.credentials", + artifactId = "credentials-manager", + version = System.getenv("LIB_VERSION") ?: return@mavenPublishing, + ) + + pom { + name.set("CredentialsManager") + description.set("Multiplatform Kotlin library for storing key-value credentials.") + } } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8295196..bd33164 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -68,6 +68,7 @@ accompanist-systemUiController = { module = "com.google.accompanist:accompanist- # Plugin classpaths kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } android-plugin = { module = "com.android.tools.build:gradle", version.ref = "android-gradle-plugin" } +vanniktech-maven-publish = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin", version.require = "0.25.3" } # Desktop microsoft-credential-storage = { module = "com.microsoft:credential-secure-storage", version.require = "1.0.0" }