diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2e5fb65 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,57 @@ +name: Publish library + +on: + release: + types: [ published ] + workflow_dispatch: + +jobs: + publish: + name: Publish package to Github Registry + + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up JDK + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 21 + cache: gradle + + - name: Derive version from release tag + id: ver + shell: bash + run: | + TAG="${{ github.event.release.tag_name || github.ref_name }}" + CLEAN="${TAG#v}" # strip leading v if present + echo "VERSION=$CLEAN" >> "$GITHUB_OUTPUT" + echo "Release version: $CLEAN" + + - name: Set root version (used by :proto via parent!!.version) + run: | + if [ -f gradle.properties ]; then + if grep -q '^version=' gradle.properties; then + sed -i "s/^version=.*/version=${{ steps.ver.outputs.VERSION }}/" gradle.properties + else + echo "version=${{ steps.ver.outputs.VERSION }}" >> gradle.properties + fi + else + echo "version=${{ steps.ver.outputs.VERSION }}" > gradle.properties + fi + echo "Using $(grep '^version=' gradle.properties)" + + - name: Build library + run: ./gradlew :formica:clean :formica:build -x check + + - name: Publish library to GitHub Packages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew :formica:publish diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4b613d3..48b8955 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,40 +1,50 @@ -name: Test the library +name: Verify the library on: pull_request: branches: - main +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: Run tests runs-on: macos-latest + steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Read cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Setup Java - uses: actions/setup-java@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v5 with: - distribution: 'corretto' - java-version: '21' + distribution: temurin + java-version: "21" + cache: gradle - - name: Run tests - run: | - ./gradlew formica:check + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v5 + + - name: Build (all modules) with tests + run: ./gradlew --no-daemon clean build - - name: Archive test report - uses: actions/upload-artifact@v4 + - name: Publish test reports (always) + if: always() + uses: actions/upload-artifact@v6 with: - name: Test report - path: build/reports/tests/test + name: test-reports + path: | + **/build/test-results/** + **/build/reports/tests/** + if-no-files-found: ignore + + - name: Publish build scans / reports (optional) + if: failure() + run: | + echo "Gradle build failed. See artifacts for reports." diff --git a/README.md b/README.md index 0f2d3d9..af20bd3 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,15 @@ Add the following dependency to your project: ```gradle dependencies { - implementation("dev.voir.formica:1.0.0-alpha02") // Not available on public now, you can publish to mavenLocal. + implementation("dev.voir.formica:1.0.0") +} + +maven { + url = uri("https://maven.pkg.github.com/VoirDev/formice") + credentials { + username = + password = + } } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 3bacfbb..b495ae2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,6 @@ plugins { // this is necessary to avoid the plugins to be loaded multiple times // in each subproject's classloader alias(libs.plugins.androidApplication) apply false - alias(libs.plugins.androidLibrary) apply false alias(libs.plugins.jetbrainsCompose) apply false alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.kotlinMultiplatform) apply false diff --git a/formica/build.gradle.kts b/formica/build.gradle.kts index bebc9c3..88ff22c 100644 --- a/formica/build.gradle.kts +++ b/formica/build.gradle.kts @@ -1,74 +1,59 @@ plugins { alias(libs.plugins.kotlinMultiplatform) - alias(libs.plugins.androidLibrary) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) id("maven-publish") - id("signing") } group = "dev.voir" -version = "1.0.0-alpha02" +version = "0.0.1" kotlin { - androidTarget { - publishLibraryVariants("release") + compilerOptions { + freeCompilerArgs.add("-opt-in=kotlin.time.ExperimentalTime") + freeCompilerArgs.add("-Xexpect-actual-classes") } - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64(), - ).forEach { iosTarget -> - iosTarget.binaries.framework { - baseName = "Formica" - isStatic = true - } - } - - sourceSets.all { - languageSettings.optIn("kotlin.experimental.ExperimentalObjCName") - } + jvm() + iosX64() + iosArm64() + iosSimulatorArm64() sourceSets { - androidMain.dependencies { - } - commonMain.dependencies { implementation(libs.kotlin.reflect) implementation(libs.kotlin.coroutines) - implementation(compose.runtime) + implementation(libs.compose.runtime) } - - iosMain.dependencies { - } - commonTest.dependencies { implementation(kotlin("test")) implementation(libs.kotlinx.coroutines.test) } + jvmMain.dependencies { + } + iosMain.dependencies { + } } } -android { - namespace = "dev.voir.formica" - compileSdk = libs.versions.android.compileSdk.get().toInt() - - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - sourceSets["main"].res.srcDirs("src/androidMain/res") - sourceSets["main"].resources.srcDirs("src/commonMain/resources") - - defaultConfig { - minSdk = libs.versions.android.minSdk.get().toInt() - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 +publishing { + publications.withType().configureEach { + pom { + name.set("formica") + description.set("Formica – Kotlin Multiplatform form manager") + url.set("https://github.com/VoirDev/formica") + } } - kotlin { - jvmToolchain(21) + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/VoirDev/formica") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } } } diff --git a/formica/src/androidMain/AndroidManifest.xml b/formica/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 8072ee0..0000000 --- a/formica/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3a21056..23514d6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,26 +1,23 @@ [versions] -agp = "8.12.0" +agp = "8.12.3" android-compileSdk = "36" android-minSdk = "24" android-targetSdk = "36" -compose-plugin = "1.8.2" # https://github.com/JetBrains/compose-multiplatform -junit = "4.13.2" -kotlin = "2.2.0" # https://kotlinlang.org/docs/releases.html +compose-plugin = "1.10.0" # https://github.com/JetBrains/compose-multiplatform +kotlin = "2.2.20" # https://kotlinlang.org/docs/releases.html kotlin-coroutines = "1.10.2" # https://github.com/Kotlin/kotlinx.coroutines -androidx-activityCompose = "1.10.1" # https://mvnrepository.com/artifact/androidx.activity/activity-compose +androidx-activityCompose = "1.12.2" # https://mvnrepository.com/artifact/androidx.activity/activity-compose +composeMultiplatform = "1.10.0" [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" } kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlin-coroutines" } -kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } -junit = { group = "junit", name = "junit", version.ref = "junit" } +compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatform" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } -androidLibrary = { id = "com.android.library", version.ref = "agp" } jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 9cff69c..148b562 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name = "FormicaLibrary" +rootProject.name = "FormicaKMP" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement {