diff --git a/.changelog/v2.0.0-0.9.0-dev1.md b/.changelog/v2.0.0-0.9.0-dev1.md new file mode 100644 index 0000000..179b921 --- /dev/null +++ b/.changelog/v2.0.0-0.9.0-dev1.md @@ -0,0 +1,5 @@ +Kotlin version: `v2.0.0` + +> [!warning] +> This is a version to test the CI configuration used for the release version, +and the content is no different from `0.9.0`. diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 9e40575..21da6ba 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,70 +19,78 @@ env: GRADLE_OPTS: "-Dfile.encoding=UTF-8" jobs: - test-build-publish: - name: Test and build - # runs-on: ubuntu-latest + test: + name: Test strategy: matrix: os: [ macos-latest, windows-latest, ubuntu-latest ] runs-on: ${{ matrix.os }} steps: - # 检出仓库代码 - - name: Check out repo - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 11 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: 8.5 + - run: gradle assemble build allTests -s + publish: + name: Publish + needs: test + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 # Setup java # https://github.com/marketplace/actions/setup-java-jdk - - name: Setup Java 11 - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - name: Test and publish to sonatype - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 with: gradle-version: 8.5 - arguments: | - assemble - build - allTests + arguments: publishToSonatype closeAndReleaseStagingRepository - --info + -s --warning-mode all -x test --build-cache -Porg.gradle.jvmargs="-XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8" -Porg.gradle.daemon=false env: - PLUGIN_AUTO: ${{ matrix.os == 'ubuntu-latest' }} + PLUGIN_AUTO: true publish-gradle-plugin: name: Publish Gradle Plugin runs-on: ubuntu-latest - needs: test-build-publish + needs: publish steps: # 检出仓库代码 - name: Check out repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Setup java # https://github.com/marketplace/actions/setup-java-jdk - name: Setup Java 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - name: Publish to gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 with: gradle-version: 8.5 arguments: | build publishPlugins - --info + -s --warning-mode all -x test --build-cache @@ -96,24 +104,18 @@ jobs: create-release: name: Create release runs-on: ubuntu-latest - needs: [ test-build-publish, publish-gradle-plugin ] + needs: [ publish, publish-gradle-plugin ] permissions: contents: write steps: - # 检出仓库代码 - - name: Check out repo - uses: actions/checkout@v3 - - # Setup java - # https://github.com/marketplace/actions/setup-java-jdk - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 - name: Create changelog - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v3 with: gradle-version: 8.5 arguments: createChangelog @@ -121,7 +123,7 @@ jobs: # https://github.com/softprops/action-gh-release # Create gitHub release - name: Create Github Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: token: ${{ secrets.FORTE_TOKEN }} draft: true diff --git a/build.gradle.kts b/build.gradle.kts index b45865e..2f59be8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,19 @@ -import love.forte.gradle.common.core.project.setup import org.jetbrains.kotlin.gradle.dsl.JvmTarget buildscript { extra["kotlin_plugin_id"] = "love.forte.plugin.suspend-transform" } -setup(IProject) +val ktVersion = libs.versions.kotlin.get() + +group = IProject.GROUP +description = IProject.DESCRIPTION +version = ktVersion + "-" + IProject.pluginVersion.toString() allprojects { - setup(IProject) + group = IProject.GROUP + description = IProject.DESCRIPTION + version = ktVersion + "-" + IProject.pluginVersion.toString() repositories { mavenCentral() @@ -36,13 +41,13 @@ apply(plugin = "suspend-transform.nexus-publish") tasks.create("createChangelog") { group = "documentation" doFirst { - val tag = "v${IProject.version}" + val tag = "v$ktVersion-${IProject.pluginVersion}" val changelogDir = rootProject.file(".changelog").apply { mkdirs() } with(File(changelogDir, "$tag.md")) { if (!exists()) { createNewFile() } - writeText("Kotlin version: `v${libs.versions.kotlin.get()}`") + writeText("Kotlin version: `v$ktVersion`") } } } diff --git a/buildSrc/src/main/kotlin/IProject.kt b/buildSrc/src/main/kotlin/IProject.kt index 898e843..2eca404 100644 --- a/buildSrc/src/main/kotlin/IProject.kt +++ b/buildSrc/src/main/kotlin/IProject.kt @@ -1,6 +1,8 @@ import love.forte.gradle.common.core.project.ProjectDetail import love.forte.gradle.common.core.project.Version +import love.forte.gradle.common.core.project.minus import love.forte.gradle.common.core.project.version +import org.gradle.api.Project object IProject : ProjectDetail() { @@ -8,7 +10,11 @@ object IProject : ProjectDetail() { const val DESCRIPTION = "Generate platform-compatible functions for Kotlin suspend functions" const val HOMEPAGE = "https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin" - override val version: Version = version(0, 9, 0) + // TODO + val ktVersion = version(2, 0, 0) + val pluginVersion = version(0, 9, 0) - version("dev1") + + override val version: Version = ktVersion - pluginVersion override val homepage: String get() = HOMEPAGE @@ -37,3 +43,9 @@ object IProject : ProjectDetail() { } } + +fun Project.setupWith(ktVersion: String) { + group = IProject.GROUP + description = IProject.DESCRIPTION + version = ktVersion + "-" + IProject.pluginVersion.toString() +} diff --git a/buildSrc/src/main/kotlin/MultiplatformTargetsConfigure.kt b/buildSrc/src/main/kotlin/MultiplatformTargetsConfigure.kt deleted file mode 100644 index 2c4f8dc..0000000 --- a/buildSrc/src/main/kotlin/MultiplatformTargetsConfigure.kt +++ /dev/null @@ -1,13 +0,0 @@ -private val coroutinesUnsupportedTargets = setOf( - "androidNativeArm32", - "androidNativeArm64", - "androidNativeX64", - "androidNativeX86", - "linuxArm32Hfp", - "linuxArm64", - "linuxMips32", - "linuxMipsel32", - "mingwX86", - "wasm32", -) - diff --git a/buildSrc/src/main/kotlin/suspend-transform.dokka-module.gradle.kts b/buildSrc/src/main/kotlin/suspend-transform.dokka-module.gradle.kts index 228f99b..f5d5724 100644 --- a/buildSrc/src/main/kotlin/suspend-transform.dokka-module.gradle.kts +++ b/buildSrc/src/main/kotlin/suspend-transform.dokka-module.gradle.kts @@ -18,7 +18,7 @@ tasks.named("dokkaHtmlPartial").configure { tasks.withType().configureEach { dokkaSourceSets.configureEach { - version = IProject.version + version = project.version documentedVisibilities.set( listOf( DokkaConfiguration.Visibility.PUBLIC, diff --git a/buildSrc/src/main/kotlin/suspend-transform.jvm-maven-publish.gradle.kts b/buildSrc/src/main/kotlin/suspend-transform.jvm-maven-publish.gradle.kts index 8a7ed8c..4eff80b 100644 --- a/buildSrc/src/main/kotlin/suspend-transform.jvm-maven-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/suspend-transform.jvm-maven-publish.gradle.kts @@ -1,7 +1,8 @@ import love.forte.gradle.common.core.Gpg -import love.forte.gradle.common.core.project.setup -import love.forte.gradle.common.publication.configure.jvmConfigPublishing +import love.forte.gradle.common.publication.configure.configPublishMaven import love.forte.gradle.common.publication.configure.publishingExtension +import love.forte.gradle.common.publication.configure.setupPom +import love.forte.gradle.common.publication.configure.signingExtension import utils.isMainPublishable plugins { @@ -9,7 +10,7 @@ plugins { id("maven-publish") } -setup(IProject) +//setup(IProject) //val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull @@ -21,34 +22,71 @@ val gpgValue = Gpg.ofSystemPropOrNull() val p = project if (isMainPublishable()) { - jvmConfigPublishing { - project = IProject - isSnapshot = project.version.toString().contains("SNAPSHOT", true) - + val isSnapshot = project.version.toString().contains("SNAPSHOT") + publishingExtension { + repositories { + mavenLocal() + if (isSnapshot) { + configPublishMaven(SnapshotRepository) + } else { + configPublishMaven(ReleaseRepository) + } + } val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { archiveClassifier.set("sources") from(sourceSets["main"].allSource) } val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { -// dependsOn(tasks.dokkaHtml) -// from(tasks.dokkaHtml.flatMap { it.outputDirectory }) archiveClassifier.set("javadoc") } - tasks.withType { - dependsOn(jarSources) - dependsOn(jarJavadoc) + publications { + create("publicationDist") { + from(components.getByName("java")) + artifact(jarSources) + artifact(jarJavadoc) + version = p.version.toString() + setupPom(p.name, IProject) + } } - artifact(jarSources) - artifact(jarJavadoc) + signingExtension { + val gpg = gpgValue ?: return@signingExtension - releasesRepository = ReleaseRepository - snapshotRepository = SnapshotRepository - - gpg = gpgValue + val (keyId, secretKey, password) = gpg + useInMemoryPgpKeys(keyId, secretKey, password) + sign(publishingExtension.publications) + } } +// jvmConfigPublishing { +// project = IProject +// isSnapshot = project.version.toString().contains("SNAPSHOT", true) +// +// val jarSources = tasks.register("${p.name}SourceJar", Jar::class) { +// archiveClassifier.set("sources") +// from(sourceSets["main"].allSource) +// } +// +// val jarJavadoc = tasks.register("${p.name}JavadocJar", Jar::class) { +//// dependsOn(tasks.dokkaHtml) +//// from(tasks.dokkaHtml.flatMap { it.outputDirectory }) +// archiveClassifier.set("javadoc") +// } +// +// tasks.withType { +// dependsOn(jarSources) +// dependsOn(jarJavadoc) +// } +// +// artifact(jarSources) +// artifact(jarJavadoc) +// +// releasesRepository = ReleaseRepository +// snapshotRepository = SnapshotRepository +// +// gpg = gpgValue +// } } diff --git a/buildSrc/src/main/kotlin/suspend-transform.multiplatform-maven-publish.gradle.kts b/buildSrc/src/main/kotlin/suspend-transform.multiplatform-maven-publish.gradle.kts index c0e90da..e1ff888 100644 --- a/buildSrc/src/main/kotlin/suspend-transform.multiplatform-maven-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/suspend-transform.multiplatform-maven-publish.gradle.kts @@ -1,7 +1,7 @@ import love.forte.gradle.common.core.Gpg -import love.forte.gradle.common.core.project.setup -import love.forte.gradle.common.core.property.systemProp -import love.forte.gradle.common.publication.configure.multiplatformConfigPublishing +import love.forte.gradle.common.publication.configure.configPublishMaven +import love.forte.gradle.common.publication.configure.publishingExtension +import love.forte.gradle.common.publication.configure.setupPom plugins { id("org.jetbrains.dokka") @@ -9,45 +9,71 @@ plugins { `maven-publish` } -setup(IProject) - tasks.withType { sourceCompatibility = "1.8" targetCompatibility = "1.8" options.encoding = "UTF-8" } - val (sonatypeUsername, sonatypePassword) = sonatypeUserInfoOrNull - val sonatypeContains = sonatypeUserInfoOrNull != null val p = project -multiplatformConfigPublishing { - project = IProject - - val jarJavadoc by tasks.registering(Jar::class) { - group = "documentation" - archiveClassifier.set("javadoc") - } - artifact(jarJavadoc) - isSnapshot = project.version.toString().contains("SNAPSHOT", true) - releasesRepository = ReleaseRepository - snapshotRepository = SnapshotRepository - gpg = Gpg.ofSystemPropOrNull() - - if (systemProp("SIMBOT_LOCAL").toBoolean()) { - logger.info("Is 'SIMBOT_LOCAL', mainHost set as null") - mainHost = null - } +val isSnapshot = p.version.toString().contains("SNAPSHOT", true) - publicationsFromMainHost += setOf("wasm", "wasm32", "wasm_js") - mainHostSupportedTargets += setOf("wasm", "wasm32", "wasm_js") +val jarJavadoc by tasks.registering(Jar::class) { + group = "documentation" + archiveClassifier.set("javadoc") } +publishing { + repositories { + mavenLocal() + if (isSnapshot) { + configPublishMaven(SnapshotRepository) + } else { + configPublishMaven(ReleaseRepository) + } + } + publications { + withType { + artifacts { + artifact(jarJavadoc) + } + setupPom(project.name, IProject) + } + } +} + +signing { + val gpg = Gpg.ofSystemPropOrNull() ?: return@signing + val (keyId, secretKey, password) = gpg + useInMemoryPgpKeys(keyId, secretKey, password) + sign(publishingExtension.publications) +} +//multiplatformConfigPublishing { +// project = IProject +// +// val jarJavadoc by tasks.registering(Jar::class) { +// group = "documentation" +// archiveClassifier.set("javadoc") +// } +// artifact(jarJavadoc) +// releasesRepository = ReleaseRepository +// snapshotRepository = SnapshotRepository +// gpg = Gpg.ofSystemPropOrNull() +// +// if (systemProp("SIMBOT_LOCAL").toBoolean()) { +// logger.info("Is 'SIMBOT_LOCAL', mainHost set as null") +// mainHost = null +// } +// +// publicationsFromMainHost += setOf("wasm", "wasm32", "wasm_js") +// mainHostSupportedTargets += setOf("wasm", "wasm32", "wasm_js") +//} // TODO see https://github.com/gradle-nexus/publish-plugin/issues/208#issuecomment-1465029831 val signingTasks: TaskCollection = tasks.withType() diff --git a/buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts b/buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts index 6f507fe..c565bde 100644 --- a/buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts @@ -1,4 +1,3 @@ -import love.forte.gradle.common.core.project.setup import love.forte.gradle.common.core.repository.Repositories import love.forte.gradle.common.publication.configure.nexusPublishConfig @@ -14,7 +13,7 @@ plugins { //version = "0.0.1" //description = "Generate platform-compatible functions for Kotlin suspend functions" -setup(IProject) +//setupWith(libs) val isPublishConfigurable = isPublishConfigurable() diff --git a/buildSrc/src/main/kotlin/utils/PropertiesUtil.kt b/buildSrc/src/main/kotlin/utils/PropertiesUtil.kt index 7a260f7..0c9560b 100644 --- a/buildSrc/src/main/kotlin/utils/PropertiesUtil.kt +++ b/buildSrc/src/main/kotlin/utils/PropertiesUtil.kt @@ -45,5 +45,7 @@ val isLinux: Boolean = systemProperty("os.name")?.contains("linux", true) ?: fal * 如果在 CI 中,则必须是 linux 平台才运作。 * 如果不在 CI 中,始终运作。 * + * 多平台发布已经不再需要分多个系统环境了, + * 不再需要判断 Main Host 了。 */ -fun isMainPublishable(): Boolean = !isCi() || (isCi() && isLinux) +fun isMainPublishable(): Boolean = true // !isCi() || (isCi() && isLinux) diff --git a/plugins/suspend-transform-plugin-gradle/build.gradle.kts b/plugins/suspend-transform-plugin-gradle/build.gradle.kts index 0530c76..98fe5ba 100644 --- a/plugins/suspend-transform-plugin-gradle/build.gradle.kts +++ b/plugins/suspend-transform-plugin-gradle/build.gradle.kts @@ -1,8 +1,7 @@ import love.forte.gradle.common.core.Gpg -import love.forte.gradle.common.core.project.setup +import love.forte.gradle.common.core.property.of import love.forte.gradle.common.publication.configure.configPublishMaven import love.forte.gradle.common.publication.configure.publishingExtension -import love.forte.gradle.common.publication.configure.setupPom import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import utils.isMainPublishable @@ -19,7 +18,7 @@ plugins { // id("suspend-transform.jvm-maven-publish") } -setup(IProject) +//setup(IProject) repositories { mavenCentral() @@ -104,7 +103,13 @@ if (isMainPublishable()) { // } withType { - setupPom(project.name, IProject) + pom { + name of project.name + group = project.group + description of project.description + version = project.version.toString() + } + // setupPom(project.name, IProject) } } }