From b0b372b1f331fff539539f6654fea5cc1f77e002 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Thu, 28 Aug 2025 14:06:41 +0300 Subject: [PATCH 01/21] Fix publish --- .github/bump_versions_in_release_branch.sh | 4 ++ .github/workflows/publish-fix.yml | 52 ++++++++++++++++++++++ .github/workflows/publish-reusable.yml | 33 +++----------- Package.swift | 3 +- bump-version-package-swift.sh | 27 +++++++++++ 5 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/publish-fix.yml create mode 100755 bump-version-package-swift.sh diff --git a/.github/bump_versions_in_release_branch.sh b/.github/bump_versions_in_release_branch.sh index 00970d3..f248e8d 100755 --- a/.github/bump_versions_in_release_branch.sh +++ b/.github/bump_versions_in_release_branch.sh @@ -33,6 +33,10 @@ properties_file="gradle.properties" current_version=$(grep -E '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2) sed -i "s/^KMP_SDK_VERSION_NAME=.*/KMP_SDK_VERSION_NAME=$version/" $properties_file +# Replace the current version with the new version in the Package.swift file +sed -i '' -E 's#(url: ")[^"]*(MindboxCommon\.xcframework\.zip)(",)#\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/'"$VERSION"'/MindboxCommon.xcframework.zip\3#g' Package.swift + + echo "Bump Common SDK version from $current_version to $version." git add $properties_file diff --git a/.github/workflows/publish-fix.yml b/.github/workflows/publish-fix.yml new file mode 100644 index 0000000..70eec73 --- /dev/null +++ b/.github/workflows/publish-fix.yml @@ -0,0 +1,52 @@ +name: Fix SDK publish + +on: + workflow_call: + inputs: + branch: + required: true + type: string + +jobs: + set-tag: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.extract_version.outputs.SDK_VERSION }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Extract SDK version + id: extract_version + run: | + SDK_VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) + echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV + echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_OUTPUT + echo "Extracted Common SDK version: $SDK_VERSION" + - name: Create tag + run: | + git tag ${{ env.SDK_VERSION }} + git push origin ${{ env.SDK_VERSION }} + + release-github: + needs: [set-tag] + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Build XCFramework + run: ./make-ios-framework.sh + - name: Github Release generation + run: ./.github/git-release-ci.sh + env: + GH_TOKEN: ${{ github.token }} + - name: Verify framework existence + run: ls -R mindbox-common/build/XCFrameworks/release + - name: Upload XCFramework to release + run: | + gh release upload ${{ needs.set-tag.outputs.tag }} \ + mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework.zip \ + --clobber + env: + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 59f050c..66389f3 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -54,7 +54,10 @@ jobs: echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_OUTPUT echo "Extracted Common SDK version: $SDK_VERSION" - # Tag will be created later after updating Package.swift + - name: Create tag + run: | + git tag ${{ env.SDK_VERSION }} + git push origin ${{ env.SDK_VERSION }} publish: needs: [set-tag] @@ -97,7 +100,7 @@ jobs: fi release-github: - needs: [publish, set-tag] + needs: [publish] runs-on: macos-latest steps: - uses: actions/checkout@v4 @@ -105,34 +108,10 @@ jobs: ref: ${{ inputs.branch }} - name: Build XCFramework run: ./make-ios-framework.sh - - name: Update Package.swift with URL and checksum - run: | - VERSION=${{ needs.set-tag.outputs.tag }} - ZIP_PATH="mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework.zip" - CHECKSUM=$(swift package compute-checksum "$ZIP_PATH") - echo "Computed checksum: $CHECKSUM" - sed -i '' -E "s#(url: \"").*(MindboxCommon.xcframework.zip)(\",)#\\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/${VERSION}/MindboxCommon.xcframework.zip\\3#g" Package.swift - sed -i '' -E "s#(checksum:\")[^"]*(\")#\\1${CHECKSUM}\\2#g" Package.swift - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add Package.swift - git commit -m "chore(spm): update Package.swift for ${VERSION}" - git push origin HEAD:${{ inputs.branch }} - - name: Create and push tag - run: | - VERSION=${{ needs.set-tag.outputs.tag }} - git tag ${VERSION} - git push origin ${VERSION} - name: Github Release generation run: ./.github/git-release-ci.sh env: GH_TOKEN: ${{ github.token }} - - name: Mark release as draft if configured - if: ${{ vars.SPM_DRAFT_RELEASE == 'true' }} - run: | - gh release edit ${{ needs.set-tag.outputs.tag }} --draft - env: - GH_TOKEN: ${{ github.token }} - name: Verify framework existence run: ls -R mindbox-common/build/XCFrameworks/release - name: Upload XCFramework to release @@ -159,4 +138,4 @@ jobs: EOF) curl -X POST "$LOOP_NOTIFICATION_WEBHOOK_URL" \ -H "Content-Type: application/json" \ - -d "$MESSAGE" + -d "$MESSAGE" \ No newline at end of file diff --git a/Package.swift b/Package.swift index 4338be5..bb8968c 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,6 @@ let package = Package( targets: [ .binaryTarget( name: "MindboxCommon", - url: "https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/1.0.3-rc/MindboxCommon.xcframework.zip", - checksum:"422dad4454addc735ea7469286dea5a828ee114c392b008af69188952ea004f4"), + url: "https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/1.0.4/MindboxCommon.xcframework.zip" ] ) \ No newline at end of file diff --git a/bump-version-package-swift.sh b/bump-version-package-swift.sh new file mode 100755 index 0000000..d6d6f90 --- /dev/null +++ b/bump-version-package-swift.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +# Get the current version from the Package.swift file +CURRENT_VERSION=$(grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' Package.swift | tr -d '"') + +# Get version from gradle.properties KMP_SDK_VERSION_NAME +VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) + +# Allow overriding VERSION and CHECKSUM via positional args +# Usage: ./bump-version-package-swift.sh +if [ -n "$1" ]; then VERSION="$1"; fi +if [ -n "$2" ]; then CHECKSUM="$2"; fi + +# Validate required variables +if [ -z "$VERSION" ]; then +echo "ERROR: VERSION is not set. Pass as first argument or set KMP_SDK_VERSION_NAME in gradle.properties." >&2 +exit 1 +fi +if [ -z "$CHECKSUM" ]; then +echo "ERROR: CHECKSUM is not set. Pass as second argument or export CHECKSUM env var." >&2 +exit 1 +fi + +# Replace the current version with the new version in the Package.swift file +sed -i '' -E 's#(url: ")[^"]*(MindboxCommon\.xcframework\.zip)(",)#\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/'"$VERSION"'/MindboxCommon.xcframework.zip\3#g' Package.swift +sed -i '' -E 's#(checksum:")[^"]*(")#\1'"$CHECKSUM"'\2#g' Package.swift \ No newline at end of file From cf0b1135ac79019a808de63e653aeaecfa6731a9 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Thu, 28 Aug 2025 14:45:17 +0300 Subject: [PATCH 02/21] Fix publish --- .github/workflows/publish-fix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-fix.yml b/.github/workflows/publish-fix.yml index 70eec73..10a5c70 100644 --- a/.github/workflows/publish-fix.yml +++ b/.github/workflows/publish-fix.yml @@ -1,7 +1,7 @@ name: Fix SDK publish on: - workflow_call: + workflow_dispatch: inputs: branch: required: true From 594b95a79cf9938f98ca5c4ac01b9344caa4abba Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Thu, 28 Aug 2025 14:56:34 +0300 Subject: [PATCH 03/21] Remove scripts --- .github/workflows/publish-fix.yml | 52 ------------------------------- bump-version-package-swift.sh | 27 ---------------- 2 files changed, 79 deletions(-) delete mode 100644 .github/workflows/publish-fix.yml delete mode 100755 bump-version-package-swift.sh diff --git a/.github/workflows/publish-fix.yml b/.github/workflows/publish-fix.yml deleted file mode 100644 index 10a5c70..0000000 --- a/.github/workflows/publish-fix.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Fix SDK publish - -on: - workflow_dispatch: - inputs: - branch: - required: true - type: string - -jobs: - set-tag: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.extract_version.outputs.SDK_VERSION }} - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - - name: Extract SDK version - id: extract_version - run: | - SDK_VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) - echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV - echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_OUTPUT - echo "Extracted Common SDK version: $SDK_VERSION" - - name: Create tag - run: | - git tag ${{ env.SDK_VERSION }} - git push origin ${{ env.SDK_VERSION }} - - release-github: - needs: [set-tag] - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - - name: Build XCFramework - run: ./make-ios-framework.sh - - name: Github Release generation - run: ./.github/git-release-ci.sh - env: - GH_TOKEN: ${{ github.token }} - - name: Verify framework existence - run: ls -R mindbox-common/build/XCFrameworks/release - - name: Upload XCFramework to release - run: | - gh release upload ${{ needs.set-tag.outputs.tag }} \ - mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework.zip \ - --clobber - env: - GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/bump-version-package-swift.sh b/bump-version-package-swift.sh deleted file mode 100755 index d6d6f90..0000000 --- a/bump-version-package-swift.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - - -# Get the current version from the Package.swift file -CURRENT_VERSION=$(grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' Package.swift | tr -d '"') - -# Get version from gradle.properties KMP_SDK_VERSION_NAME -VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) - -# Allow overriding VERSION and CHECKSUM via positional args -# Usage: ./bump-version-package-swift.sh -if [ -n "$1" ]; then VERSION="$1"; fi -if [ -n "$2" ]; then CHECKSUM="$2"; fi - -# Validate required variables -if [ -z "$VERSION" ]; then -echo "ERROR: VERSION is not set. Pass as first argument or set KMP_SDK_VERSION_NAME in gradle.properties." >&2 -exit 1 -fi -if [ -z "$CHECKSUM" ]; then -echo "ERROR: CHECKSUM is not set. Pass as second argument or export CHECKSUM env var." >&2 -exit 1 -fi - -# Replace the current version with the new version in the Package.swift file -sed -i '' -E 's#(url: ")[^"]*(MindboxCommon\.xcframework\.zip)(",)#\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/'"$VERSION"'/MindboxCommon.xcframework.zip\3#g' Package.swift -sed -i '' -E 's#(checksum:")[^"]*(")#\1'"$CHECKSUM"'\2#g' Package.swift \ No newline at end of file From 67eedf9069ccc46671fa819f3d2841696423f607 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Mon, 22 Sep 2025 14:53:44 +0300 Subject: [PATCH 04/21] WMSDK-532: Prepare for submodule --- .github/git-release-ci.sh | 2 +- gradle.properties | 3 -- gradle/libs.versions.toml | 3 +- mindbox-common/build.gradle.kts | 13 +++--- .../mindbox/mobile_sdk/utils/MindboxUtils.kt | 45 +++++++++++++++++++ settings.gradle.kts | 6 +++ 6 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt diff --git a/.github/git-release-ci.sh b/.github/git-release-ci.sh index c9e47b3..3fdde1c 100755 --- a/.github/git-release-ci.sh +++ b/.github/git-release-ci.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -version=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) +version=$(awk -F '"' '/val kmpSdkVersionName: String/ { print $2; exit }' mindbox-common/build.gradle.kts) is_beta=false if [[ $version == *"rc"* ]]; then diff --git a/gradle.properties b/gradle.properties index 44726a3..d435239 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,3 @@ kotlin.code.style=official #Android android.useAndroidX=true android.nonTransitiveRClass=true - -#SDK -KMP_SDK_VERSION_NAME=1.0.4 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e6e2144..2db7e98 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,10 @@ [versions] -agp = "8.2.0" +agp = "8.9.1" kotlin = "1.9.22" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } [plugins] androidLibrary = { id = "com.android.library", version.ref = "agp" } diff --git a/mindbox-common/build.gradle.kts b/mindbox-common/build.gradle.kts index 583379c..a56fc3d 100644 --- a/mindbox-common/build.gradle.kts +++ b/mindbox-common/build.gradle.kts @@ -1,18 +1,20 @@ + import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask plugins { - id("org.jetbrains.kotlin.multiplatform") version "1.9.22" + id("org.jetbrains.kotlin.multiplatform") id("com.android.library") id("maven-publish") - id("com.vanniktech.maven.publish") version "0.33.0" - id("org.jlleitschuh.gradle.ktlint") version "12.1.1" + id("com.vanniktech.maven.publish") + id("org.jlleitschuh.gradle.ktlint") } group = "cloud.mindbox" -version = providers.gradleProperty("KMP_SDK_VERSION_NAME").get() +val kmpSdkVersionName: String = "1.0.4" +version = kmpSdkVersionName println("KMP_SDK_VERSION_NAME: $version") kotlin { @@ -24,7 +26,7 @@ kotlin { } } } - publishLibraryVariants("release") + publishLibraryVariants("release", "debug") } val xcFrameworkName = "MindboxCommon" @@ -44,6 +46,7 @@ kotlin { sourceSets { commonMain.dependencies { + implementation(kotlin("stdlib")) } commonTest.dependencies { implementation(kotlin("test")) diff --git a/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt b/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt new file mode 100644 index 0000000..7184e69 --- /dev/null +++ b/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt @@ -0,0 +1,45 @@ +package cloud.mindbox.mobile_sdk.utils + +import kotlin.time.Duration +import kotlin.time.Duration.Companion.nanoseconds + + +public object MindboxUtils { + public object Stopwatch { + + public const val INIT_SDK: String = "INIT_SDK" + public const val GET_PUSH_TOKENS: String = "GET_PUSH_TOKENS" + public const val INIT_PUSH_SERVICES: String = "INIT_PUSH_SERVICES" + + private val entries: MutableMap by lazy { mutableMapOf() } + + /*** + * Start tracking duration with tag + */ + public fun start(tag: String) { + entries[tag] = System.nanoTime() + } + + /*** + * Stop tracking duration from call of [start] with the same tag + * + * @return Duration in nanoseconds or null if tag not found + */ + public fun stop(tag: String): Duration? = + track(tag)?.also { + entries.remove(tag) + } + + /*** + * Track duration from call of [start] with the same tag + * + * @return Duration in nanoseconds or null if tag not found + */ + public fun track(tag: String): Duration? = + entries[tag]?.let { start -> + val now = System.nanoTime() + (now - start).nanoseconds + } + } +} + diff --git a/settings.gradle.kts b/settings.gradle.kts index 0b7d17a..92512a8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,11 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { + plugins { + id("org.jetbrains.kotlin.multiplatform") version "1.9.22" + id("com.android.library") version "8.9.1" + id("com.vanniktech.maven.publish") version "0.33.0" + id("org.jlleitschuh.gradle.ktlint") version "12.1.1" + } repositories { google() gradlePluginPortal() From b33fc78c58d07078ae9b9444151048eb326bea88 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Mon, 29 Sep 2025 17:59:28 +0300 Subject: [PATCH 05/21] WMSDK-533: Add test for MindboxUtils --- gradle/libs.versions.toml | 2 + .../cloud/mindbox/mobile_sdk/utils/Time.kt | 5 +++ .../mindbox/mobile_sdk/utils/MindboxUtils.kt | 6 +-- .../cloud/mindbox/mobile_sdk/utils/Time.kt | 3 ++ .../mobile_sdk/utils/MindboxUtilsTest.kt | 45 +++++++++++++++++++ .../mindbox/mobile_sdk/utils/TimeTest.kt | 13 ++++++ .../cloud/mindbox/mobile_sdk/utils/Time.kt | 8 ++++ 7 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt rename mindbox-common/src/{androidMain => commonMain}/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt (92%) create mode 100644 mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt create mode 100644 mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtilsTest.kt create mode 100644 mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/TimeTest.kt create mode 100644 mindbox-common/src/iosMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2db7e98..7294d4b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,12 @@ [versions] agp = "8.9.1" kotlin = "1.9.22" +kotlinxCoroutinesTest = "1.8.1" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutinesTest" } [plugins] androidLibrary = { id = "com.android.library", version.ref = "agp" } diff --git a/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt b/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt new file mode 100644 index 0000000..48632fb --- /dev/null +++ b/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt @@ -0,0 +1,5 @@ +package cloud.mindbox.mobile_sdk.utils + +internal actual fun getSystemNanoTime(): Long { + return System.nanoTime() +} diff --git a/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt b/mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt similarity index 92% rename from mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt rename to mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt index 7184e69..9bada3d 100644 --- a/mindbox-common/src/androidMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt +++ b/mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtils.kt @@ -3,7 +3,6 @@ package cloud.mindbox.mobile_sdk.utils import kotlin.time.Duration import kotlin.time.Duration.Companion.nanoseconds - public object MindboxUtils { public object Stopwatch { @@ -17,7 +16,7 @@ public object MindboxUtils { * Start tracking duration with tag */ public fun start(tag: String) { - entries[tag] = System.nanoTime() + entries[tag] = getSystemNanoTime() } /*** @@ -37,9 +36,8 @@ public object MindboxUtils { */ public fun track(tag: String): Duration? = entries[tag]?.let { start -> - val now = System.nanoTime() + val now = getSystemNanoTime() (now - start).nanoseconds } } } - diff --git a/mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt b/mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt new file mode 100644 index 0000000..7f6e648 --- /dev/null +++ b/mindbox-common/src/commonMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt @@ -0,0 +1,3 @@ +package cloud.mindbox.mobile_sdk.utils + +internal expect fun getSystemNanoTime(): Long diff --git a/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtilsTest.kt b/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtilsTest.kt new file mode 100644 index 0000000..a69ab29 --- /dev/null +++ b/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/MindboxUtilsTest.kt @@ -0,0 +1,45 @@ +package cloud.mindbox.mobile_sdk.utils + +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import kotlin.test.* +import kotlin.time.Duration + +class MindboxUtilsTest { + + @Test + fun `stopwatch start stop in 1 seconds`() = runBlocking { + MindboxUtils.Stopwatch.start("test") + delay(1000) + val duration: Duration? = MindboxUtils.Stopwatch.stop("test") + assertEquals(duration?.inWholeSeconds, 1) + } + + @Test + fun `stopwatch stop not started tag`() { + MindboxUtils.Stopwatch.start("test2") + val duration: Duration? = MindboxUtils.Stopwatch.stop("test") + assertNull(duration) + } + + @Test + fun `stopwatch track 1 seconds twice`() = runBlocking { + MindboxUtils.Stopwatch.start("test3") + delay(1000) + val duration1: Duration? = MindboxUtils.Stopwatch.track("test3") + assertEquals(1, duration1?.inWholeSeconds) + delay(1000) + val duration2: Duration? = MindboxUtils.Stopwatch.track("test3") + assertEquals(2, duration2?.inWholeSeconds) + } + + @Test + fun `stopwatch stop twice`() { + MindboxUtils.Stopwatch.start("test4") + val duration1: Duration? = MindboxUtils.Stopwatch.stop("test4") + assertNotNull(duration1) + + val duration2: Duration? = MindboxUtils.Stopwatch.stop("test4") + assertNull(duration2) + } +} diff --git a/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/TimeTest.kt b/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/TimeTest.kt new file mode 100644 index 0000000..3cb9236 --- /dev/null +++ b/mindbox-common/src/commonTest/kotlin/cloud/mindbox/mobile_sdk/utils/TimeTest.kt @@ -0,0 +1,13 @@ +package cloud.mindbox.mobile_sdk.utils + +import kotlin.test.* + +class TimeTest { + + @Test + fun `get system nano time returns a positive value`() { + val nanoTime = getSystemNanoTime() + assertTrue(nanoTime > 0) + } + +} diff --git a/mindbox-common/src/iosMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt b/mindbox-common/src/iosMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt new file mode 100644 index 0000000..e41347f --- /dev/null +++ b/mindbox-common/src/iosMain/kotlin/cloud/mindbox/mobile_sdk/utils/Time.kt @@ -0,0 +1,8 @@ +package cloud.mindbox.mobile_sdk.utils + +import platform.posix.CLOCK_MONOTONIC +import platform.posix.clock_gettime_nsec_np + +internal actual fun getSystemNanoTime(): Long { + return clock_gettime_nsec_np(CLOCK_MONOTONIC.toUInt()).toLong() +} From 6357a58797127d9ab2a68b851d1476010eaaf303 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Tue, 30 Sep 2025 09:32:07 +0300 Subject: [PATCH 06/21] WMSDK-533: Add kotlinx.coroutines.test dependency --- MindboxCommon.podspec | 13 +++++++++++++ mindbox-common/build.gradle.kts | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 MindboxCommon.podspec diff --git a/MindboxCommon.podspec b/MindboxCommon.podspec new file mode 100644 index 0000000..175ced8 --- /dev/null +++ b/MindboxCommon.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'MindboxCommon' + s.version = '1.0.4' + s.summary = 'Mindbox KMP Common framework (Local)' + s.homepage = 'https://github.com/mindbox-cloud/kmp-common-sdk' + s.license = { :type => "CC BY-NC-ND 4.0", :text => "See LICENSE.md in the repository: https://github.com/mindbox-cloud/kmp-common-sdk" } + s.author = { "Mindbox" => "ios-sdk@mindbox.ru" } + + s.source = { :http => '' } + + s.platform = :ios, '12.0' + s.vendored_frameworks = 'mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework' + end \ No newline at end of file diff --git a/mindbox-common/build.gradle.kts b/mindbox-common/build.gradle.kts index a56fc3d..c543420 100644 --- a/mindbox-common/build.gradle.kts +++ b/mindbox-common/build.gradle.kts @@ -46,10 +46,11 @@ kotlin { sourceSets { commonMain.dependencies { - implementation(kotlin("stdlib")) + implementation(libs.kotlin.stdlib) } commonTest.dependencies { - implementation(kotlin("test")) + implementation(libs.kotlin.test) + implementation(libs.kotlinx.coroutines.test) } } } From afddd2be9be5753a9abdde14a394c39f667deb3b Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Tue, 30 Sep 2025 14:05:31 +0300 Subject: [PATCH 07/21] WMSDK-533: Add Package.swift for local develop --- Package.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index bb8968c..7c491a9 100644 --- a/Package.swift +++ b/Package.swift @@ -16,6 +16,7 @@ let package = Package( targets: [ .binaryTarget( name: "MindboxCommon", - url: "https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/1.0.4/MindboxCommon.xcframework.zip" + path: "mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework" + ) ] ) \ No newline at end of file From c94c56a8be6894e7aac1f5cc916603e80db30bce Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Wed, 1 Oct 2025 11:09:23 +0300 Subject: [PATCH 08/21] WMSDK-533: addassembleMindboxCommonReleaseXCFramework --- MindboxCommon.podspec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MindboxCommon.podspec b/MindboxCommon.podspec index 175ced8..2d6568c 100644 --- a/MindboxCommon.podspec +++ b/MindboxCommon.podspec @@ -6,7 +6,12 @@ Pod::Spec.new do |s| s.license = { :type => "CC BY-NC-ND 4.0", :text => "See LICENSE.md in the repository: https://github.com/mindbox-cloud/kmp-common-sdk" } s.author = { "Mindbox" => "ios-sdk@mindbox.ru" } - s.source = { :http => '' } + s.source = { :git => 'https://github.com/mindbox-cloud/kmp-common-sdk.git', :tag => s.version.to_s } + + s.prepare_command = <<-CMD + chmod +x gradlew + ./gradlew assembleMindboxCommonReleaseXCFramework + CMD s.platform = :ios, '12.0' s.vendored_frameworks = 'mindbox-common/build/XCFrameworks/release/MindboxCommon.xcframework' From ca7ce213d124c473baab967a70692369ee5fd232 Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Thu, 2 Oct 2025 17:19:38 +0300 Subject: [PATCH 09/21] WMSDK-545: Change publish version --- mindbox-common/build.gradle.kts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mindbox-common/build.gradle.kts b/mindbox-common/build.gradle.kts index c543420..a190d92 100644 --- a/mindbox-common/build.gradle.kts +++ b/mindbox-common/build.gradle.kts @@ -13,9 +13,8 @@ plugins { } group = "cloud.mindbox" -val kmpSdkVersionName: String = "1.0.4" -version = kmpSdkVersionName -println("KMP_SDK_VERSION_NAME: $version") +version = providers.gradleProperty("SDK_VERSION_NAME").get() +println("mindbox-common version: $version") kotlin { androidTarget { @@ -26,7 +25,7 @@ kotlin { } } } - publishLibraryVariants("release", "debug") + publishLibraryVariants("release") } val xcFrameworkName = "MindboxCommon" @@ -49,7 +48,7 @@ kotlin { implementation(libs.kotlin.stdlib) } commonTest.dependencies { - implementation(libs.kotlin.test) + implementation(kotlin("test")) implementation(libs.kotlinx.coroutines.test) } } From 29253c37e94b37cd55305c669e6572f16f94506e Mon Sep 17 00:00:00 2001 From: Egor Kitselyuk Date: Thu, 2 Oct 2025 17:33:27 +0300 Subject: [PATCH 10/21] WMSDK-545: Add sdk version stub --- gradle.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gradle.properties b/gradle.properties index d435239..c8b4a26 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,3 +9,5 @@ kotlin.code.style=official #Android android.useAndroidX=true android.nonTransitiveRClass=true + +SDK_VERSION_NAME= From b31e57430501d4b1d9bf5d8743d88c31b85e9873 Mon Sep 17 00:00:00 2001 From: sozinov Date: Thu, 9 Oct 2025 14:39:53 +0300 Subject: [PATCH 11/21] WMSDK-0000: publish to maven central --- mindbox-common/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mindbox-common/build.gradle.kts b/mindbox-common/build.gradle.kts index 583379c..e985276 100644 --- a/mindbox-common/build.gradle.kts +++ b/mindbox-common/build.gradle.kts @@ -90,7 +90,7 @@ ktlint { } mavenPublishing { - publishToMavenCentral() + publishToMavenCentral("CENTRAL_PORTAL") if (System.getenv("CI") == "true") { signAllPublications() From 7b31d9cc14ebda8a8b3fd6d1932e46152a48768d Mon Sep 17 00:00:00 2001 From: Sergei Semko <28645140+justSmK@users.noreply.github.com> Date: Thu, 9 Oct 2025 21:12:56 +0300 Subject: [PATCH 12/21] Update podspec after release 2.14.2 for local builds --- MindboxCommon.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MindboxCommon.podspec b/MindboxCommon.podspec index 2d6568c..bf265a4 100644 --- a/MindboxCommon.podspec +++ b/MindboxCommon.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MindboxCommon' - s.version = '1.0.4' + s.version = '2.14.2' s.summary = 'Mindbox KMP Common framework (Local)' s.homepage = 'https://github.com/mindbox-cloud/kmp-common-sdk' s.license = { :type => "CC BY-NC-ND 4.0", :text => "See LICENSE.md in the repository: https://github.com/mindbox-cloud/kmp-common-sdk" } From 1f24aba6f611c96e4ec6b64025699a37b818a1a1 Mon Sep 17 00:00:00 2001 From: Vailence Date: Wed, 29 Oct 2025 12:22:44 +0500 Subject: [PATCH 13/21] WMSDK-547 Added manual release branch workflow --- .../manual-prepare_release_branch.yml | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml index f32dedd..a7ec937 100644 --- a/.github/workflows/manual-prepare_release_branch.yml +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -1,10 +1,10 @@ -name: "Manual Release Prep: Branch & Version Bump" +name: "1. Release branch manual preparation" on: workflow_dispatch: inputs: release_version: - description: 'Release version (e.g. 1.2.3 or 1.2.3-rc)' + description: 'Release version (e.g. 1.2.3)' required: true source_branch: description: 'Create branch from' @@ -23,7 +23,7 @@ jobs: - name: Check version matches semver or semver-rc run: | VER="${{ github.event.inputs.release_version }}" - echo "→ release_version = $VER" + echo "✅ release_version = $VER" if ! [[ "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then echo "❌ release_version must be X.Y.Z or X.Y.Z-rc" exit 1 @@ -92,38 +92,14 @@ jobs: run: | git push origin "${{ steps.bump.outputs.release_branch }}" - check_sdk_version: - name: Check SDK Version - runs-on: ubuntu-latest - needs: bump_and_branch - steps: - - name: Checkout the release branch - uses: actions/checkout@v4 - with: - ref: ${{ needs.bump_and_branch.outputs.release_branch }} - fetch-depth: 0 - - - name: Pull latest changes - run: git pull - - - name: Validate sdkVersion - run: | - EXPECT="${{ github.event.inputs.release_version }}" - SDK_VERSION=$(grep -E '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2) - echo "→ Found in code: $SDK_VERSION, expected: $EXPECT" - if [ "$SDK_VERSION" != "$EXPECT" ]; then - echo "❌ SDK version does not match!" - exit 1 - fi - create_pull_request: name: Create Pull Request runs-on: ubuntu-latest - needs: [bump_and_branch, check_sdk_version] + needs: [bump_and_branch] steps: - name: Create PR via GitHub CLI env: - GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + GH_TOKEN: ${{ github.token }} SRC: ${{ needs.bump_and_branch.outputs.release_branch }} DST: ${{ github.event.inputs.target_branch }} REPO: ${{ github.repository }} From a251f5803346ba85236d60c1d47d43692ef12f22 Mon Sep 17 00:00:00 2001 From: Vailence Date: Wed, 29 Oct 2025 12:23:51 +0500 Subject: [PATCH 14/21] WMSDK-547 Updated bump version script --- .github/bump_versions_in_release_branch.sh | 88 ++++++++++++++----- .../manual-prepare_release_branch.yml | 4 +- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/.github/bump_versions_in_release_branch.sh b/.github/bump_versions_in_release_branch.sh index f248e8d..f7e7d8f 100755 --- a/.github/bump_versions_in_release_branch.sh +++ b/.github/bump_versions_in_release_branch.sh @@ -1,49 +1,91 @@ #!/bin/bash +set -e -# Check if the parameter is provided +# === Validate input === if [ $# -eq 0 ]; then echo "Please provide the release version number as a parameter." exit 1 fi -# Check if the version number matches the semver format if ! [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then echo "The release version number does not match the semver format (X.Y.Z or X.Y.Z-rc)." exit 1 fi -# Check the current Git branch +version=$1 current_branch=$(git symbolic-ref --short HEAD) -echo "Currently on branch: $current_branch" +echo "→ Currently on branch: $current_branch" if [[ ! $current_branch =~ ^(release|support)/[0-9]+\.[0-9]+\.[0-9]+(-rc)?$ ]]; then - echo "The current Git branch ($current_branch) is not in the format 'release/X.Y.Z', 'release/X.Y.Z-rc', 'support/X.Y.Z' or 'support/X.Y.Z-rc'." - exit 1 + echo "❌ The current Git branch ($current_branch) is not in the correct format." + exit 1 fi -version=$1 +# === Update gradle.properties === +properties_file="gradle.properties" +if [ ! -f "$properties_file" ]; then + echo "❌ $properties_file not found." + exit 1 +fi -# Show the current directory and its files -echo "Current directory: $(pwd)" -echo "Files in the current directory:" -ls -l +current_version=$(grep -E '^SDK_VERSION_NAME=' "$properties_file" | cut -d'=' -f2) +echo "→ Current SDK_VERSION_NAME: ${current_version:-}" +echo "→ Updating SDK_VERSION_NAME to $version" -# Add changelog to the index and create a commit -properties_file="gradle.properties" -current_version=$(grep -E '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d'=' -f2) -sed -i "s/^KMP_SDK_VERSION_NAME=.*/KMP_SDK_VERSION_NAME=$version/" $properties_file +if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "s/^SDK_VERSION_NAME=.*/SDK_VERSION_NAME=$version/" "$properties_file" +else + sed -i "s/^SDK_VERSION_NAME=.*/SDK_VERSION_NAME=$version/" "$properties_file" +fi + +grep "^SDK_VERSION_NAME=" "$properties_file" +git add "$properties_file" -# Replace the current version with the new version in the Package.swift file -sed -i '' -E 's#(url: ")[^"]*(MindboxCommon\.xcframework\.zip)(",)#\1https://github.com/mindbox-cloud/kmp-common-sdk/releases/download/'"$VERSION"'/MindboxCommon.xcframework.zip\3#g' Package.swift +# === Update MindboxCommon.podspec (only s.version) === +podspec_file="MindboxCommon.podspec" +if [ -f "$podspec_file" ]; then + echo "→ Updating $podspec_file version to $version" + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' -E "s|^[[:space:]]*s\.version[[:space:]]*=.*| s.version = '$version'|" "$podspec_file" + else + sed -i -E "s|^[[:space:]]*s\.version[[:space:]]*=.*| s.version = '$version'|" "$podspec_file" + fi -echo "Bump Common SDK version from $current_version to $version." + grep "s.version" "$podspec_file" + git add "$podspec_file" +else + echo "⚠️ $podspec_file not found, skipping podspec update." +fi + +# === Commit changes === +echo "" +git commit -m "Bump Common SDK version to $version" || echo "No changes to commit" + +# === Validation === +echo "→ Validating version bump..." +new_version=$(grep -E '^SDK_VERSION_NAME=' "$properties_file" | cut -d'=' -f2) -git add $properties_file -git commit -m "Bump Common SDK version to $version" +if [ "$new_version" != "$version" ]; then + echo "❌ Validation failed: expected SDK_VERSION_NAME=$version but found $new_version" + exit 1 +fi -echo "Pushing changes to branch: $current_branch" -if ! git push origin $current_branch; then - echo "Failed to push changes to the origin $current_branch" +if [ -f "$podspec_file" ]; then + podspec_version=$(grep -E "^[[:space:]]*s\.version" "$podspec_file" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+(-rc)?") + if [ "$podspec_version" != "$version" ]; then + echo "❌ Validation failed: expected s.version=$version but found $podspec_version" exit 1 + fi fi + +echo "✅ Validation passed: version successfully updated to $version" + +# === Push changes === +echo "→ Pushing changes to branch: $current_branch" +if ! git push origin "$current_branch"; then + echo "❌ Failed to push changes to origin/$current_branch" + exit 1 +fi + +echo "✅ bump_versions_in_release_branch.sh completed successfully." diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml index a7ec937..b4ba131 100644 --- a/.github/workflows/manual-prepare_release_branch.yml +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -99,7 +99,7 @@ jobs: steps: - name: Create PR via GitHub CLI env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} SRC: ${{ needs.bump_and_branch.outputs.release_branch }} DST: ${{ github.event.inputs.target_branch }} REPO: ${{ github.repository }} @@ -110,4 +110,4 @@ jobs: --base "$DST" \ --head "$SRC" \ --title "Release ${{ github.event.inputs.release_version }}" \ - --body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST" \ No newline at end of file + --body "Updates the release version to ${{ github.event.inputs.release_version }}. Automated PR: merge $SRC into $DST" From 4a101a34286f7f2bdd05e2252653eb69d6f156f1 Mon Sep 17 00:00:00 2001 From: Vailence Date: Wed, 29 Oct 2025 13:06:21 +0500 Subject: [PATCH 15/21] WMSDK-547 Update publish --- .github/git-release-ci.sh | 2 +- .github/workflows/prepare_release_branch.yml | 93 ------------------- .../publish-from-master-or-support.yml | 2 +- .github/workflows/publish-manual.yml | 6 +- .github/workflows/publish-reusable.yml | 86 +++++++---------- 5 files changed, 37 insertions(+), 152 deletions(-) delete mode 100644 .github/workflows/prepare_release_branch.yml diff --git a/.github/git-release-ci.sh b/.github/git-release-ci.sh index 3fdde1c..264ebc9 100755 --- a/.github/git-release-ci.sh +++ b/.github/git-release-ci.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -version=$(awk -F '"' '/val kmpSdkVersionName: String/ { print $2; exit }' mindbox-common/build.gradle.kts) +version=$(awk -F= '/^[[:space:]]*SDK_VERSION_NAME[[:space:]]*=/ { val=$2; sub(/#.*/,"",val); gsub(/[[:space:]]/,"",val); print val; exit }' gradle.properties) is_beta=false if [[ $version == *"rc"* ]]; then diff --git a/.github/workflows/prepare_release_branch.yml b/.github/workflows/prepare_release_branch.yml deleted file mode 100644 index 9cf3e79..0000000 --- a/.github/workflows/prepare_release_branch.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Prepare release branch - -on: - push: - branches: - - 'release/*.*.*' - - 'support/*.*.*' - -jobs: - extract_version: - if: github.event.created - name: Extract Version - runs-on: ubuntu-latest - outputs: - version: ${{ steps.extract.outputs.version }} - steps: - - name: Extract version from branch name - id: extract - run: | - BRANCH_NAME="${{ github.ref_name }}" - echo "BRANCH_NAME: $BRANCH_NAME" - VERSION="${BRANCH_NAME#release/}" - VERSION="${VERSION#support/}" - echo "VERSION: $VERSION" - echo "version=${VERSION}" >> $GITHUB_OUTPUT - - bump_version: - name: Bump Version - runs-on: ubuntu-latest - needs: extract_version - outputs: - version2: ${{ steps.bump.outputs.version2 }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Configure Git identity for GitHub Action Bot - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - - name: Bump version - run: ./.github/bump_versions_in_release_branch.sh "${{ needs.extract_version.outputs.version }}" - - - name: Ouput version - id: bump - run: | - echo "version2=${{ needs.extract_version.outputs.version }}" >> $GITHUB_OUTPUT - - check_sdk_version: - name: Check SDK Version - runs-on: ubuntu-latest - needs: bump_version - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Pull latest changes - run: git pull - - - name: Check if KMP_SDK_VERSION_NAME matches VERSION - run: | - SDK_VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) - EXPECTED_VERSION=${{ needs.bump_version.outputs.version2 }} - - if [ "$SDK_VERSION" != "$EXPECTED_VERSION" ]; then - echo "SDK_VERSION_NAME ($ACTUAL_VERSION) does not match the expected version ($EXPECTED_VERSION)." - exit 1 - fi - shell: bash - - create_pull_request: - name: Create Pull Request - runs-on: ubuntu-latest - needs: check_sdk_version - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Create Pull Request - run: | - gh pr create \ - --base master \ - --head ${{ github.ref_name }} \ - --title "${{ github.ref_name }}" \ - --body "Updates the release version to ${{ github.ref_name }}" - PR_URL=$(gh pr view --json url --jq '.url') - echo "PR_URL=$PR_URL" >> $GITHUB_ENV - env: - GH_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} - diff --git a/.github/workflows/publish-from-master-or-support.yml b/.github/workflows/publish-from-master-or-support.yml index 74a4cb4..a8625cd 100644 --- a/.github/workflows/publish-from-master-or-support.yml +++ b/.github/workflows/publish-from-master-or-support.yml @@ -1,4 +1,4 @@ -name: Common SDK publish from master or support branch +name: 2. Auto Github Release on: pull_request: diff --git a/.github/workflows/publish-manual.yml b/.github/workflows/publish-manual.yml index 4051d1d..05f7f46 100644 --- a/.github/workflows/publish-manual.yml +++ b/.github/workflows/publish-manual.yml @@ -1,4 +1,4 @@ -name: Common SDK publish RC manual +name: 2. Manual Github Release on: @@ -10,8 +10,8 @@ jobs: steps: - name: Check if branch matches pattern run: | - if ! echo "${{ github.ref_name }}" | grep -q "release/.*-rc"; then - echo "Branch name must match pattern 'release/*-rc' (e.g. release/2.13.2-rc)" + if ! echo "${{ github.ref_name }}" | grep -q "release/"; then + echo "Branch name must match pattern 'release' (e.g. release/2.13.2)" exit 1 fi diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 66389f3..8e6c0e3 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -1,4 +1,4 @@ -name: SDK publish +name: 2. Github Release Reusable on: workflow_call: @@ -11,10 +11,11 @@ jobs: checks: runs-on: macos-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: ref: ${{ inputs.branch }} fetch-depth: 2 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: @@ -42,7 +43,7 @@ jobs: needs: [checks] runs-on: ubuntu-latest outputs: - tag: ${{ steps.extract_version.outputs.SDK_VERSION }} + tag: ${{ steps.extract_version.outputs.sdk_version }} steps: - uses: actions/checkout@v4 with: @@ -50,58 +51,20 @@ jobs: - name: Extract SDK version id: extract_version run: | - SDK_VERSION=$(grep '^KMP_SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) - echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_ENV - echo "SDK_VERSION=$SDK_VERSION" >> $GITHUB_OUTPUT - echo "Extracted Common SDK version: $SDK_VERSION" + SDK_VERSION=$(grep '^SDK_VERSION_NAME=' gradle.properties | cut -d '=' -f2) + echo "Extracted SDK version: ${SDK_VERSION}" + echo "sdk_version=${SDK_VERSION}" >> $GITHUB_OUTPUT + echo "SDK_VERSION=${SDK_VERSION}" >> $GITHUB_ENV - name: Create tag run: | - git tag ${{ env.SDK_VERSION }} - git push origin ${{ env.SDK_VERSION }} - - publish: - needs: [set-tag] - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.branch }} - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - cache: 'gradle' - - name: Prepare to publish - run: | - echo '${{secrets.GPGKEYCONTENTS}}' | base64 -d > /tmp/publish_key.gpg - gpg --quiet --batch --yes --decrypt --passphrase="${{secrets.SECRETPASSPHRASE}}" \ - --output /tmp/secret.gpg /tmp/publish_key.gpg - echo "signing.password=${{secrets.SIGNINGPASSWORD}}" >> gradle.properties - echo "signing.keyId=${{secrets.SIGNINGKEYID}}" >> gradle.properties - echo "signing.secretKeyRingFile=/tmp/secret.gpg" >> gradle.properties - echo "mavenCentralUsername=${{secrets.CENTER_PORTAL_USERNAME}}" >> gradle.properties - echo "mavenCentralPassword=${{secrets.CENTER_PORTAL_PASSWORD}}" >> gradle.properties - env: - signingpassword: ${{secrets.SIGNINGPASSWORD}} - signingkeyId: ${{secrets.SIGNINGKEYID}} - SECRETPASSPHRASE: ${{secrets.SECRETPASSPHRASE}} - GPGKEYCONTENTS: ${{secrets.GPGKEYCONTENTS}} - SONATYPE_CONNECT_TIMEOUT_SECONDS: 60 - SONATYPE_CLOSE_TIMEOUT_SECONDS: 900 - ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' - - name: Publish to Central Portal - # Change github variable CENTER_PORTAL_AUTO_RELEASE to set up auto release Maven Central - run: | - if [ "${{ vars.CENTER_PORTAL_AUTO_RELEASE }}" = "true" ]; then - ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache - else - ./gradlew publishToMavenCentral --no-configuration-cache - fi - + git tag "${{ env.SDK_VERSION }}" + git push origin "${{ env.SDK_VERSION }}" + release-github: - needs: [publish] + needs: [set-tag] runs-on: macos-latest + outputs: + tag: ${{ needs.set-tag.outputs.tag }} steps: - uses: actions/checkout@v4 with: @@ -122,9 +85,23 @@ jobs: env: GH_TOKEN: ${{ github.token }} - message-to-loop-if-success: + trigger-repo-b: needs: [release-github] runs-on: ubuntu-latest + steps: + - name: Trigger workflow in repo B + run: | + echo "Triggering workflow in repo B..." + echo "TAG=${{ needs.release-github.outputs.tag }}" + curl -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ + https://api.github.com/repos/vailence/kmp-common-sdk-spm/dispatches \ + -d "{\"event_type\": \"download_xcframework\", \"client_payload\": {\"version\": \"${{ needs.release-github.outputs.tag }}\"}}" + + message-to-loop-if-success: + needs: [trigger-repo-b] + runs-on: ubuntu-latest steps: - name: Send message to LOOP env: @@ -133,9 +110,10 @@ jobs: run: | MESSAGE=$(cat < Date: Wed, 29 Oct 2025 15:23:47 +0500 Subject: [PATCH 16/21] WMSDK-547: Adds merge job to workflow --- .github/workflows/publish-reusable.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 8e6c0e3..7be0948 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -98,9 +98,27 @@ jobs: -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ https://api.github.com/repos/vailence/kmp-common-sdk-spm/dispatches \ -d "{\"event_type\": \"download_xcframework\", \"client_payload\": {\"version\": \"${{ needs.release-github.outputs.tag }}\"}}" + + merge: + needs: [trigger-repo-b] + if: startsWith(github.head_ref, 'release/') && github.base_ref == 'master' + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.PAT_FOR_TRIGGERING_BRANCH_PROTECTION }} + steps: + - name: Checkout develop branch + uses: actions/checkout@v5 + with: + ref: develop + - name: Create Pull Request + run: gh pr create --base develop --head master --title "Merge 'master' into 'develop' after release" --body "Automated Pull Request to merge 'master' into 'develop' after release" + - name: Merge Pull Request + run: | + pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') + gh pr merge $pr_number --merge --auto message-to-loop-if-success: - needs: [trigger-repo-b] + needs: [merge] runs-on: ubuntu-latest steps: - name: Send message to LOOP From 61fa5e2f6696150ef7aa375f9adc0db6154b7142 Mon Sep 17 00:00:00 2001 From: Vailence Date: Thu, 30 Oct 2025 18:52:44 +0500 Subject: [PATCH 17/21] WMSDK-547 Fix PR --- .github/workflows/publish-reusable.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 7be0948..583f2b6 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -85,22 +85,22 @@ jobs: env: GH_TOKEN: ${{ github.token }} - trigger-repo-b: + trigger-kmp-common-spm: needs: [release-github] runs-on: ubuntu-latest steps: - name: Trigger workflow in repo B run: | - echo "Triggering workflow in repo B..." + echo "Triggering workflow in repo KMP-COMMON-SDK-SPM..." echo "TAG=${{ needs.release-github.outputs.tag }}" curl -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ - https://api.github.com/repos/vailence/kmp-common-sdk-spm/dispatches \ + https://api.github.com/repos/mindbox-cloud/kmp-common-sdk-spm/dispatches \ -d "{\"event_type\": \"download_xcframework\", \"client_payload\": {\"version\": \"${{ needs.release-github.outputs.tag }}\"}}" merge: - needs: [trigger-repo-b] + needs: [trigger-kmp-common-spm] if: startsWith(github.head_ref, 'release/') && github.base_ref == 'master' runs-on: ubuntu-latest env: From e45e4feec198bd37dd482c8738c824cfd1314a57 Mon Sep 17 00:00:00 2001 From: Vailence Date: Sat, 1 Nov 2025 14:48:43 +0500 Subject: [PATCH 18/21] WMSDK-547 Fix PR --- .../manual-prepare_release_branch.yml | 2 +- .github/workflows/publish-reusable.yml | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/manual-prepare_release_branch.yml b/.github/workflows/manual-prepare_release_branch.yml index b4ba131..1483bdd 100644 --- a/.github/workflows/manual-prepare_release_branch.yml +++ b/.github/workflows/manual-prepare_release_branch.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: release_version: - description: 'Release version (e.g. 1.2.3)' + description: 'Release version (e.g. 1.2.3 or 1.2.3-rc)' required: true source_branch: description: 'Create branch from' diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index 583f2b6..da7872e 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -116,22 +116,3 @@ jobs: run: | pr_number=$(gh pr list --base develop --head master --json number --jq '.[0].number') gh pr merge $pr_number --merge --auto - - message-to-loop-if-success: - needs: [merge] - runs-on: ubuntu-latest - steps: - - name: Send message to LOOP - env: - LOOP_NOTIFICATION_WEBHOOK_URL: ${{ secrets.LOOP_NOTIFICATION_WEBHOOK_URL }} - VERSION: ${{ github.ref_name }} - run: | - MESSAGE=$(cat < Date: Tue, 11 Nov 2025 20:10:35 +0300 Subject: [PATCH 19/21] WMSDK-554: Bump kotlin to 2.2.21 --- gradle/libs.versions.toml | 4 ++-- settings.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7294d4b..0ac13bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] agp = "8.9.1" -kotlin = "1.9.22" -kotlinxCoroutinesTest = "1.8.1" +kotlin = "2.2.21" +kotlinxCoroutinesTest = "1.9.0" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 92512a8..35c000b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { plugins { - id("org.jetbrains.kotlin.multiplatform") version "1.9.22" + id("org.jetbrains.kotlin.multiplatform") version "2.2.21" id("com.android.library") version "8.9.1" id("com.vanniktech.maven.publish") version "0.33.0" id("org.jlleitschuh.gradle.ktlint") version "12.1.1" From 4a0d93c597e665ba8527a5f86cac399ebf736ecd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 12:43:28 +0000 Subject: [PATCH 20/21] Bump Common SDK version to 2.14.4 --- MindboxCommon.podspec | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MindboxCommon.podspec b/MindboxCommon.podspec index bf265a4..71bccc0 100644 --- a/MindboxCommon.podspec +++ b/MindboxCommon.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MindboxCommon' - s.version = '2.14.2' + s.version = '2.14.4' s.summary = 'Mindbox KMP Common framework (Local)' s.homepage = 'https://github.com/mindbox-cloud/kmp-common-sdk' s.license = { :type => "CC BY-NC-ND 4.0", :text => "See LICENSE.md in the repository: https://github.com/mindbox-cloud/kmp-common-sdk" } diff --git a/gradle.properties b/gradle.properties index c8b4a26..a84ea30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ kotlin.code.style=official android.useAndroidX=true android.nonTransitiveRClass=true -SDK_VERSION_NAME= +SDK_VERSION_NAME=2.14.4 From 09ad390a870d1b359313e69b788fa2b928b006c2 Mon Sep 17 00:00:00 2001 From: Sergei Semko <28645140+justSmK@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:09:46 +0300 Subject: [PATCH 21/21] WMSDK-0000: ci: switch GitHub Actions workflow from macos-latest to macos-26 runner --- .github/workflows/lint_unitTests_build.yml | 2 +- .github/workflows/publish-reusable.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint_unitTests_build.yml b/.github/workflows/lint_unitTests_build.yml index 52e362c..32ea0ef 100644 --- a/.github/workflows/lint_unitTests_build.yml +++ b/.github/workflows/lint_unitTests_build.yml @@ -13,7 +13,7 @@ on: jobs: checks: - runs-on: macos-latest + runs-on: macos-26 steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/publish-reusable.yml b/.github/workflows/publish-reusable.yml index da7872e..2680ea3 100644 --- a/.github/workflows/publish-reusable.yml +++ b/.github/workflows/publish-reusable.yml @@ -9,7 +9,7 @@ on: jobs: checks: - runs-on: macos-latest + runs-on: macos-26 steps: - uses: actions/checkout@v5 with: @@ -62,7 +62,7 @@ jobs: release-github: needs: [set-tag] - runs-on: macos-latest + runs-on: macos-26 outputs: tag: ${{ needs.set-tag.outputs.tag }} steps: