Skip to content

Commit

Permalink
Adds snapshot publishing (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
JayShortway committed Jun 13, 2024
1 parent 455ab20 commit f11f789
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 40 deletions.
80 changes: 80 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: 2.1

orbs:
android: circleci/[email protected]

commands:
install-android-sdk-on-macos:
description: Install the Android SDK on macOS
steps:
- run:
name: Install Android SDK commandline tools
command: brew install --cask android-commandlinetools
- run:
name: Set Android SDK environment variables
command: |
echo 'export ANDROID_HOME="$HOMEBREW_PREFIX/share/android-commandlinetools"' >> "$BASH_ENV"
echo 'export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"' >> "$BASH_ENV"
- android/accept-licenses
- run:
name: Install Android SDK platform tools
command: sdkmanager "platform-tools"
require-snapshot-version:
description: Check that the current version is a SNAPSHOT version
steps:
- run:
name: Check that the current version is a SNAPSHOT version
command: |
set -euo pipefail
file_path="gradle/libs.versions.toml"
version=$(grep 'revenuecat-kmp = ' "$file_path" | awk -F ' = ' '{print $2}' | tr -d '"')
if [[ ! "$version" =~ -SNAPSHOT$ ]]; then
echo "$version is not a SNAPSHOT version. Exiting..."
exit 1
else
echo "$version is a SNAPSHOT version. Proceeding..."
fi
executors:
xcode15:
macos:
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
environment:
# Avoid waiting for Homebrew to auto update existing packages, as everything we care about is
# freshly installed.
HOMEBREW_NO_AUTO_UPDATE: 1

jobs:
deploy-snapshot:
executor: xcode15
steps:
- checkout
- require-snapshot-version
- install-android-sdk-on-macos
- android/restore-gradle-cache
- android/restore-build-cache
- run:
name: Set environment variables for publishing
command: |
echo 'export ORG_GRADLE_PROJECT_mavenCentralUsername="$SONATYPE_NEXUS_TOKEN_USERNAME"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_mavenCentralPassword="$SONATYPE_NEXUS_TOKEN_PASSWORD"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_signingInMemoryKey="$SIGNING_GPG_IN_MEMORY"' >> "$BASH_ENV"
echo 'export ORG_GRADLE_PROJECT_signingInMemoryKeyPassword="$GPG_SIGNING_KEY_PW_NEW"' >> "$BASH_ENV"
- run:
name: Publish snapshot to Maven Central
command: ./gradlew publishAllPublicationsToMavenCentralRepository
- android/save-gradle-cache
- android/save-build-cache

workflows:
on-main:
# On all pushes to main, except when it's a scheduled pipeline.
when:
and:
- equal: [ main, << pipeline.git.branch >> ]
- not:
equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
jobs:
- deploy-snapshot:
context: maven-central-publishing
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class LibraryConventionPlugin : Plugin<Project> {
apply("dev.adamko.dokkatoo-html")
apply("io.gitlab.arturbosch.detekt")
apply("com.vanniktech.maven.publish")
apply("com.gradleup.nmcp")
}

extensions.configure<KotlinMultiplatformExtension> {
Expand Down
45 changes: 13 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.SonatypeHost
import io.gitlab.arturbosch.detekt.Detekt
import nmcp.NmcpExtension
import nmcp.NmcpPlugin
import org.gradle.configurationcache.extensions.capitalized

plugins {
Expand All @@ -19,45 +18,27 @@ plugins {
alias(libs.plugins.adamko.dokkatoo.html)
alias(libs.plugins.arturbosch.detekt).apply(false)
alias(libs.plugins.vanniktech.mavenPublish).apply(false)
alias(libs.plugins.gradleup.nmcp).apply(false)
}

allprojects {
group = "" // FIXME Check publishing
group = "com.revenuecat.purchases"
version = rootProject.libs.versions.revenuecat.kmp.get()

// NmcpPlugin publishes to a local repo when running assemble, meaning we need signing
// credentials for every assemble. This avoids that.
if (gradle.startParameter.taskNames.contains("publishAllPublicationsToCentralPortal")) {
// Remove when https://github.com/vanniktech/gradle-maven-publish-plugin/issues/722 is fixed.
plugins.withType<NmcpPlugin> {
configure<NmcpExtension>() {
publishAllPublications {
username = System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername")
password = System.getenv("ORG_GRADLE_PROJECT_mavenCentralPassword")
publicationType = "AUTOMATIC"
}
}
}
}

plugins.withType<MavenPublishPlugin> {
configure<MavenPublishBaseExtension> {
// Re-enable when https://github.com/vanniktech/gradle-maven-publish-plugin/issues/722
// is fixed.
// publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true)
publishToMavenCentral(SonatypeHost.DEFAULT, automaticRelease = true)
signAllPublications()

coordinates(
groupId = group.toString(),
artifactId = "kobankat-${project.name}",
artifactId = "purchases-kmp-${project.name}",
version = version.toString()
)
pom {
name.set("KobanKat (${project.name})")
description.set("RevenueCat SDK for Kotlin Multiplatform")
name.set("purchases-kmp-(${project.name})")
description.set("Mobile subscriptions in hours, not months.")
inceptionYear.set("2024")
url.set("https://github.com/JayShortway/kobankat")
url.set("https://github.com/RevenueCat/purchases-kmp")
licenses {
license {
name.set("The MIT License (MIT)")
Expand All @@ -67,15 +48,15 @@ allprojects {
}
developers {
developer {
id.set("JayShortway")
name.set("Jay Shortway")
url.set("https://github.com/JayShortway")
id.set("revenuecat")
name.set("RevenueCat, Inc.")
url.set("https://www.revenuecat.com/")
}
}
scm {
url.set("https://github.com/JayShortway/kobankat")
connection.set("scm:git:https://github.com/JayShortway/kobankat.git")
developerConnection.set("scm:git:ssh://[email protected]/JayShortway/kobankat.git")
url.set("https://github.com/RevenueCat/purchases-kmp")
connection.set("scm:git:git://github.com/RevenueCat/purchases-kmp.git")
developerConnection.set("scm:git:ssh://[email protected]/RevenueCat/purchases-kmp.git")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/api/core.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <core>
// Library unique name: <com.revenuecat.purchases:core>
abstract interface com.revenuecat.purchases.kmp.models/PurchasingData { // com.revenuecat.purchases.kmp.models/PurchasingData|null[0]
abstract val productId // com.revenuecat.purchases.kmp.models/PurchasingData.productId|{}productId[0]
abstract fun <get-productId>(): kotlin/String // com.revenuecat.purchases.kmp.models/PurchasingData.productId.<get-productId>|<get-productId>(){}[0]
Expand Down
2 changes: 1 addition & 1 deletion datetime/api/datetime.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <datetime>
// Library unique name: <com.revenuecat.purchases:datetime>
final val com.revenuecat.purchases.kmp.datetime/allExpirationInstants // com.revenuecat.purchases.kmp.datetime/allExpirationInstants|@cocoapods.PurchasesHybridCommon.RCCustomerInfo{}allExpirationInstants[0]
final fun (cocoapods.PurchasesHybridCommon/RCCustomerInfo).<get-allExpirationInstants>(): kotlin.collections/Map<kotlin/String, kotlinx.datetime/Instant?> // com.revenuecat.purchases.kmp.datetime/allExpirationInstants.<get-allExpirationInstants>|<get-allExpirationInstants>@cocoapods.PurchasesHybridCommon.RCCustomerInfo(){}[0]
final val com.revenuecat.purchases.kmp.datetime/allPurchaseInstants // com.revenuecat.purchases.kmp.datetime/allPurchaseInstants|@cocoapods.PurchasesHybridCommon.RCCustomerInfo{}allPurchaseInstants[0]
Expand Down
2 changes: 1 addition & 1 deletion either/api/either.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <either>
// Library unique name: <com.revenuecat.purchases:either>
final class com.revenuecat.purchases.kmp.either/FailedPurchase { // com.revenuecat.purchases.kmp.either/FailedPurchase|null[0]
constructor <init>(com.revenuecat.purchases.kmp/PurchasesError, kotlin/Boolean) // com.revenuecat.purchases.kmp.either/FailedPurchase.<init>|<init>(com.revenuecat.purchases.kmp.PurchasesError;kotlin.Boolean){}[0]
final fun component1(): com.revenuecat.purchases.kmp/PurchasesError // com.revenuecat.purchases.kmp.either/FailedPurchase.component1|component1(){}[0]
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
codingfeline-buildkonfig = { id = "com.codingfeline.buildkonfig", version = "0.15.1" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
gradleup-nmcp = { id = "com.gradleup.nmcp", version = "0.0.4" }
jetbrains-compose = { id = "org.jetbrains.compose", version = "1.6.10" }
kotlin-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.15.0-Beta.2" }
vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.27.0" }
vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" }
2 changes: 1 addition & 1 deletion paywalls/api/paywalls.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <paywalls>
// Library unique name: <com.revenuecat.purchases:paywalls>
abstract interface com.revenuecat.purchases.kmp.ui.revenuecatui/PaywallListener { // com.revenuecat.purchases.kmp.ui.revenuecatui/PaywallListener|null[0]
open fun onPurchaseCancelled() // com.revenuecat.purchases.kmp.ui.revenuecatui/PaywallListener.onPurchaseCancelled|onPurchaseCancelled(){}[0]
open fun onPurchaseCompleted(cocoapods.PurchasesHybridCommon/RCCustomerInfo, cocoapods.PurchasesHybridCommon/RCStoreTransaction) // com.revenuecat.purchases.kmp.ui.revenuecatui/PaywallListener.onPurchaseCompleted|onPurchaseCompleted(cocoapods.PurchasesHybridCommon.RCCustomerInfo;cocoapods.PurchasesHybridCommon.RCStoreTransaction){}[0]
Expand Down
2 changes: 1 addition & 1 deletion result/api/result.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// - Show manifest properties: true
// - Show declarations: true

// Library unique name: <result>
// Library unique name: <com.revenuecat.purchases:result>
final suspend fun (cocoapods.PurchasesHybridCommon/RCPurchases).com.revenuecat.purchases.kmp.result/awaitCustomerInfoResult(com.revenuecat.purchases.kmp/CacheFetchPolicy = ...): kotlin/Result<cocoapods.PurchasesHybridCommon/RCCustomerInfo> // com.revenuecat.purchases.kmp.result/awaitCustomerInfoResult|awaitCustomerInfoResult@cocoapods.PurchasesHybridCommon.RCPurchases(com.revenuecat.purchases.kmp.CacheFetchPolicy){}[0]
final suspend fun (cocoapods.PurchasesHybridCommon/RCPurchases).com.revenuecat.purchases.kmp.result/awaitGetProductsResult(kotlin.collections/List<kotlin/String>): kotlin/Result<kotlin.collections/List<cocoapods.PurchasesHybridCommon/RCStoreProduct>> // com.revenuecat.purchases.kmp.result/awaitGetProductsResult|awaitGetProductsResult@cocoapods.PurchasesHybridCommon.RCPurchases(kotlin.collections.List<kotlin.String>){}[0]
final suspend fun (cocoapods.PurchasesHybridCommon/RCPurchases).com.revenuecat.purchases.kmp.result/awaitLogInResult(kotlin/String): kotlin/Result<com.revenuecat.purchases.kmp.ktx/SuccessfulLogin> // com.revenuecat.purchases.kmp.result/awaitLogInResult|[email protected](kotlin.String){}[0]
Expand Down

0 comments on commit f11f789

Please sign in to comment.