touchlab / KMMBridge

KMMBridge is a set of Gradle tooling that facilitates publishing and consuming pre-built KMM (Kotlin Multiplatform Mobile) Xcode Framework binaries. See https://kmmbridge.touchlab.co/docs to get started.
https://kmmbridge.touchlab.co/
Apache License 2.0
339 stars 20 forks source link

Semantic version not recognized (0.1.0) #246

Closed alvindizon closed 4 weeks ago

alvindizon commented 1 month ago

Summary

So I've been trying out KMMBridge via this Codelab, and encountered a head scratcher--I specified my KMP library to have a library version of 0.1.0. But the logs in Github Actions show that it doesn't recognize this and instead thinks that the version is 0.1.0.0. nextVersion parameter must be a valid semver string. Current value: 0.1.0.0

Details

Following the Codelab, I've defined my KMP library version in my gradle.properties like this

#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.caching=true
org.gradle.configuration-cache=false

#Kotlin
kotlin.code.style=official

#Android
android.useAndroidX=true
android.nonTransitiveRClass=true

LIBRARY_VERSION=0.1.0

My build.gradle.kts looks like this:

import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import java.util.Properties

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.kotlinxSerialization)
    id("maven-publish")
    alias(libs.plugins.kmmbridge)
}

val VERSION = project.property("LIBRARY_VERSION") as String

version = VERSION
group = "com.alvindizon.newsreaderkmp"

kotlin {
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
        publishAllLibraryVariants()
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "NewsReaderKMP"
            isStatic = true
        }
    }

    sourceSets {
        commonMain.dependencies {
            //put your multiplatform dependencies here
            implementation(libs.kotlinx.serialization.json)
            implementation(libs.kotlinx.coroutines.core)
        }
        commonTest.dependencies {
            implementation(libs.kotlin.test)
        }
    }
}

android {
    namespace = "com.alvindizon.newsreaderkmp"
    compileSdk = 34
    defaultConfig {
        minSdk = 24
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

addGithubPackagesRepository()

kmmbridge {
    mavenPublishArtifacts()
    spm()
}

And I have defined Github Action to publish on demand as follows:

name: Publish All
on:
  workflow_dispatch:
#  push:
#    branches:
#      - "main"
jobs:
  call-kmmbridge-publish:
    permissions:
      contents: write
      packages: write
    uses: touchlab/KMMBridgeGithubWorkflow/.github/workflows/faktorybuildautoversion.yml@v1.1
    with:
      jvmVersion: 17
      versionBaseProperty: LIBRARY_VERSION
      publishTask: kmmBridgePublish publishKotlinMultiplatformPublicationToGitHubPackagesRepository publishAndroidDebugPublicationToGitHubPackagesRepository publishAndroidReleasePublicationToGitHubPackagesRepository

But I've encountered the following error:

Run touchlab/autoversion-tagmarker@main
Error: nextVersion parameter must be a valid semver string. Current value: 0.1.0.0

It seems the library version is not being parsed properly.

Reproduction

See https://github.com/alvindizon/NewsReaderKMP/actions/runs/9243837175/job/25428451920 and https://github.com/alvindizon/NewsReaderKMP.

Expected result

Semantic versioning should be recognized by touchlab/autoversion-tagmaker

Current state

Github Actions fails due to Error: nextVersion parameter must be a valid semver string. Current value: 0.1.0.0

Possible Fix

N/A

hanrw commented 1 month ago

just update LIBRARY_VERSION=0.1.0 to LIBRARY_VERSION=0.1

alvindizon commented 1 month ago

What if we have a patch? Like 0.1.1?

samhill303 commented 4 weeks ago

If you're using autoversion, then it will incrementally append a version. The version set in LIBRARY_VERSION is a prefix to that auto incremented version.

You can choose to specify versions manually with manualVersions()

We have a new version of KMMBridge coming out soon which no longer uses auto versioning