From 4eb77365f4e9944c83a4b7fc0096939ffbf7e7af Mon Sep 17 00:00:00 2001 From: kigawa Date: Mon, 18 Aug 2025 22:47:55 +0900 Subject: [PATCH 01/13] Configure CI/CD pipeline for Maven Central deployment and update plugin configurations for publishing and signing integrations. Refactor artifact naming and align dependencies across modules. --- .github/workflows/deploy-maven-central.yml | 73 +++++++++++++++++++ build.gradle.kts | 12 +++ gradle-plugin/build.gradle.kts | 60 ++++++++++++++- .../net/kigawa/renlin/RenlinCompilerPlugin.kt | 2 +- kotlin-plugin/build.gradle.kts | 60 ++++++++++++++- sample-project/build.gradle.kts | 2 +- .../kotlin/net/kigawa/sample/TestComponent.kt | 5 +- settings.gradle.kts | 1 + 8 files changed, 205 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/deploy-maven-central.yml diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml new file mode 100644 index 0000000..99a507a --- /dev/null +++ b/.github/workflows/deploy-maven-central.yml @@ -0,0 +1,73 @@ +name: Deploy to Maven Central + +on: + pull_request: + types: [opened, synchronize] + branches: [master] + +jobs: + deploy: + if: github.head_ref == 'develop' || startsWith(github.head_ref, 'release/') + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Set up Java + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v2 + + - name: Determine version from branch + id: version + run: | + BRANCH_NAME="${{ github.head_ref }}" + echo "Source branch: $BRANCH_NAME" + + # Set version based on branch name + if [[ "$BRANCH_NAME" =~ ^release/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + echo "Release branch detected, version: $VERSION" + elif [[ "$BRANCH_NAME" == "master" ]]; then + VERSION="1.0.0" + echo "Master branch detected, using base version: $VERSION" + else + SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g') + VERSION="1.0.0-${SANITIZED_BRANCH}-SNAPSHOT" + echo "Feature branch detected, version: $VERSION" + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Final version: $VERSION" + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish plugins to Maven Central + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + VERSION: ${{ steps.version.outputs.version }} + run: | + echo "Publishing plugins version: $VERSION" + ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=$VERSION + + - name: Auto-merge PR + if: success() + uses: pascalgn/merge-action@v0.15.6 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + merge_method: squash \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 9776158..2d8df36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") version "1.9.0" application + id("io.github.gradle-nexus.publish-plugin") version "1.3.0" } group = "net.kigawa" @@ -21,3 +22,14 @@ tasks.test { kotlin { jvmToolchain(8) } + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + username.set(System.getenv("MAVEN_USERNAME")) + password.set(System.getenv("MAVEN_PASSWORD")) + } + } +} diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts index 053d86b..308d5c3 100644 --- a/gradle-plugin/build.gradle.kts +++ b/gradle-plugin/build.gradle.kts @@ -2,11 +2,17 @@ plugins { kotlin("jvm") `java-gradle-plugin` `maven-publish` + signing } group = "net.kigawa" version = "1.0.0" +repositories { + gradlePluginPortal() + mavenCentral() +} + gradlePlugin { plugins { create("renlinCompiler") { @@ -28,16 +34,66 @@ kotlin { jvmToolchain(8) } +java { + withSourcesJar() + withJavadocJar() +} + +// Version from environment or project property +version = project.findProperty("version") as String? ?: "1.0.0" + publishing { publications { register("mavenJava", MavenPublication::class) { from(components["kotlin"]) groupId = "net.kigawa" - artifactId = "net.kigawa.gradle.plugin" - version = "1.0.0" + artifactId = "renlin-compiler-gradle-plugin" + + pom { + name.set("Renlin Compiler Gradle Plugin") + description.set("Gradle plugin that enables automatic value injection for @AutoFill annotated parameters using Kotlin Compiler Plugin") + url.set("https://github.com/kigawa01/kcp-for-renlin") + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("kigawa01") + name.set("kigawa") + email.set("kigawa.inbox@gmail.com") + } + } + + scm { + connection.set("scm:git:git://github.com/kigawa01/kcp-for-renlin.git") + developerConnection.set("scm:git:ssh://github.com:kigawa01/kcp-for-renlin.git") + url.set("https://github.com/kigawa01/kcp-for-renlin") + } + } } } repositories { mavenLocal() } +} + + +signing { + val signingKey: String? by project + val signingPassword: String? by project + val hasSigningCredentials = (System.getenv("GPG_SIGNING_KEY") != null && System.getenv("GPG_SIGNING_PASSWORD") != null) || + (signingKey != null && signingPassword != null) + + if (hasSigningCredentials) { + useInMemoryPgpKeys( + System.getenv("GPG_SIGNING_KEY") ?: signingKey, + System.getenv("GPG_SIGNING_PASSWORD") ?: signingPassword + ) + sign(publishing.publications) + } } \ No newline at end of file diff --git a/gradle-plugin/src/main/kotlin/net/kigawa/renlin/RenlinCompilerPlugin.kt b/gradle-plugin/src/main/kotlin/net/kigawa/renlin/RenlinCompilerPlugin.kt index 887ce52..38c6018 100644 --- a/gradle-plugin/src/main/kotlin/net/kigawa/renlin/RenlinCompilerPlugin.kt +++ b/gradle-plugin/src/main/kotlin/net/kigawa/renlin/RenlinCompilerPlugin.kt @@ -49,7 +49,7 @@ class RenlinCompilerPlugin : KotlinCompilerPluginSupportPlugin { override fun getPluginArtifact(): SubpluginArtifact { return SubpluginArtifact( groupId = "net.kigawa", - artifactId = "kotlin-plugin", + artifactId = "renlin-compiler-kotlin-plugin", version = "1.0.0", ) } diff --git a/kotlin-plugin/build.gradle.kts b/kotlin-plugin/build.gradle.kts index 2fb3229..f9075d7 100644 --- a/kotlin-plugin/build.gradle.kts +++ b/kotlin-plugin/build.gradle.kts @@ -1,11 +1,17 @@ plugins { kotlin("jvm") `maven-publish` + signing } group = "net.kigawa" version = "1.0.0" +repositories { + gradlePluginPortal() + mavenCentral() +} + dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.0") @@ -18,16 +24,66 @@ kotlin { jvmToolchain(8) } +java { + withSourcesJar() + withJavadocJar() +} + +// Version from environment or project property +version = project.findProperty("version") as String? ?: "1.0.0" + publishing { publications { register("mavenJava", MavenPublication::class) { from(components["kotlin"]) groupId = "net.kigawa" - artifactId = "kotlin-plugin" - version = "1.0.0" + artifactId = "renlin-compiler-kotlin-plugin" + + pom { + name.set("Renlin Compiler Kotlin Plugin") + description.set("Kotlin Compiler Plugin that automatically injects values for @AutoFill annotated parameters during compilation") + url.set("https://github.com/kigawa01/kcp-for-renlin") + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("kigawa01") + name.set("kigawa") + email.set("kigawa.inbox@gmail.com") + } + } + + scm { + connection.set("scm:git:git://github.com/kigawa01/kcp-for-renlin.git") + developerConnection.set("scm:git:ssh://github.com:kigawa01/kcp-for-renlin.git") + url.set("https://github.com/kigawa01/kcp-for-renlin") + } + } } } repositories { mavenLocal() } +} + + +signing { + val signingKey: String? by project + val signingPassword: String? by project + val hasSigningCredentials = (System.getenv("GPG_SIGNING_KEY") != null && System.getenv("GPG_SIGNING_PASSWORD") != null) || + (signingKey != null && signingPassword != null) + + if (hasSigningCredentials) { + useInMemoryPgpKeys( + System.getenv("GPG_SIGNING_KEY") ?: signingKey, + System.getenv("GPG_SIGNING_PASSWORD") ?: signingPassword + ) + sign(publishing.publications) + } } \ No newline at end of file diff --git a/sample-project/build.gradle.kts b/sample-project/build.gradle.kts index b348625..2d20acc 100644 --- a/sample-project/build.gradle.kts +++ b/sample-project/build.gradle.kts @@ -25,7 +25,7 @@ repositories { dependencies { implementation(kotlin("stdlib")) - implementation("net.kigawa:kotlin-plugin:1.0.0") + implementation("net.kigawa:renlin-compiler-kotlin-plugin:1.0.0") testImplementation(kotlin("test")) } diff --git a/sample-project/src/main/kotlin/net/kigawa/sample/TestComponent.kt b/sample-project/src/main/kotlin/net/kigawa/sample/TestComponent.kt index 0b316ad..037f832 100644 --- a/sample-project/src/main/kotlin/net/kigawa/sample/TestComponent.kt +++ b/sample-project/src/main/kotlin/net/kigawa/sample/TestComponent.kt @@ -7,10 +7,7 @@ class TestComponent { fun render(@AutoFill key: String? = null, content: String) { println("TestComponent.render called with key: '$key', content: '$content'") } - - fun process(@AutoFill id: String?, @AutoFill name: String?, value: Int) { - println("TestComponent.process called with id: '$id', name: '$name', value: $value") - } + } // 通常の関数でもアノテーション付きパラメータを使用可能 diff --git a/settings.gradle.kts b/settings.gradle.kts index bf028e0..e738e2a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,6 @@ pluginManagement { repositories { + gradlePluginPortal() mavenCentral() } plugins { From aacf73ff8d38ab5f21ad8a2a22ba86be0eda10f8 Mon Sep 17 00:00:00 2001 From: kigawa Date: Mon, 18 Aug 2025 22:54:24 +0900 Subject: [PATCH 02/13] Configure CI/CD pipeline for Maven Central deployment and update plugin configurations for publishing and signing integrations. Refactor artifact naming and align dependencies across modules. --- .github/workflows/deploy-maven-central.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 99a507a..6679f1e 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -3,7 +3,7 @@ name: Deploy to Maven Central on: pull_request: types: [opened, synchronize] - branches: [master] + branches: [main] jobs: deploy: @@ -39,9 +39,9 @@ jobs: if [[ "$BRANCH_NAME" =~ ^release/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then VERSION="${BASH_REMATCH[1]}" echo "Release branch detected, version: $VERSION" - elif [[ "$BRANCH_NAME" == "master" ]]; then + elif [[ "$BRANCH_NAME" == "main" ]]; then VERSION="1.0.0" - echo "Master branch detected, using base version: $VERSION" + echo "Main branch detected, using base version: $VERSION" else SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g') VERSION="1.0.0-${SANITIZED_BRANCH}-SNAPSHOT" From ba75266e9a181bccab0171ac91c87d686b2303c2 Mon Sep 17 00:00:00 2001 From: kigawa Date: Mon, 18 Aug 2025 22:55:21 +0900 Subject: [PATCH 03/13] Configure CI/CD pipeline for Maven Central deployment and update plugin configurations for publishing and signing integrations. Refactor artifact naming and align dependencies across modules. --- .github/workflows/deploy-maven-central.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 6679f1e..2349f3d 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -65,9 +65,9 @@ jobs: echo "Publishing plugins version: $VERSION" ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=$VERSION - - name: Auto-merge PR + - name: Enable auto-merge for PR if: success() - uses: pascalgn/merge-action@v0.15.6 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - merge_method: squash \ No newline at end of file + run: | + gh pr merge --squash --auto + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 7000d1779f5b0c4c0c1e6dd0d3eb8952cd23298a Mon Sep 17 00:00:00 2001 From: kigawa Date: Mon, 18 Aug 2025 23:26:24 +0900 Subject: [PATCH 04/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 2349f3d..3cec369 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -26,9 +26,6 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v2 - - name: Determine version from branch id: version run: | From c50f0d1445b7bbab3369bfc9ba8139f1bcdc5d98 Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 00:02:02 +0900 Subject: [PATCH 05/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 3cec369..e97d261 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -51,6 +51,14 @@ jobs: - name: Set up Gradle uses: gradle/gradle-build-action@v2 + - name: Debug environment variables + run: | + echo "Maven Username present: ${{ secrets.MAVEN_USERNAME != '' }}" + echo "Maven Password present: ${{ secrets.MAVEN_PASSWORD != '' }}" + echo "GPG Key present: ${{ secrets.MAVEN_GPG_PRIVATE_KEY != '' }}" + echo "GPG Passphrase present: ${{ secrets.MAVEN_GPG_PASSPHRASE != '' }}" + echo "Version: ${{ steps.version.outputs.version }}" + - name: Publish plugins to Maven Central env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} @@ -60,7 +68,11 @@ jobs: VERSION: ${{ steps.version.outputs.version }} run: | echo "Publishing plugins version: $VERSION" - ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=$VERSION + ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository \ + -Pversion=$VERSION \ + -PsonatypeUsername="${{ secrets.MAVEN_USERNAME }}" \ + -PsonatypePassword="${{ secrets.MAVEN_PASSWORD }}" \ + --info - name: Enable auto-merge for PR if: success() From 644e55fa01a50487eeafe8fd5ccf626af8b5b5ff Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 00:15:06 +0900 Subject: [PATCH 06/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2d8df36..9f0480d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,8 +28,8 @@ nexusPublishing { sonatype { nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - username.set(System.getenv("MAVEN_USERNAME")) - password.set(System.getenv("MAVEN_PASSWORD")) + username.set(System.getenv("MAVEN_USERNAME") ?: project.findProperty("sonatypeUsername") as String?) + password.set(System.getenv("MAVEN_PASSWORD") ?: project.findProperty("sonatypePassword") as String?) } } } From dd5863c1ecf6997e96b2d3311e903dedebf0ceea Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:10:08 +0900 Subject: [PATCH 07/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 62 ++++++++++++---------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index e97d261..4aea3d3 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -13,19 +13,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 with: gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - + - name: Set up Java uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - + + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v2 + - name: Determine version from branch id: version run: | @@ -37,20 +40,17 @@ jobs: VERSION="${BASH_REMATCH[1]}" echo "Release branch detected, version: $VERSION" elif [[ "$BRANCH_NAME" == "main" ]]; then - VERSION="1.0.0" + VERSION="1.2.1" echo "Main branch detected, using base version: $VERSION" else SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g') - VERSION="1.0.0-${SANITIZED_BRANCH}-SNAPSHOT" + VERSION="1.2.1-${SANITIZED_BRANCH}-SNAPSHOT" echo "Feature branch detected, version: $VERSION" fi echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Final version: $VERSION" - - - name: Set up Gradle - uses: gradle/gradle-build-action@v2 - + - name: Debug environment variables run: | echo "Maven Username present: ${{ secrets.MAVEN_USERNAME != '' }}" @@ -58,25 +58,33 @@ jobs: echo "GPG Key present: ${{ secrets.MAVEN_GPG_PRIVATE_KEY != '' }}" echo "GPG Passphrase present: ${{ secrets.MAVEN_GPG_PASSPHRASE != '' }}" echo "Version: ${{ steps.version.outputs.version }}" - - - name: Publish plugins to Maven Central + + - name: Publish package + uses: gradle/gradle-build-action@v2 + with: + arguments: | + -PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }} + -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }} + -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }} + -PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }} + allTests publishAndReleaseToMavenCentral env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - GPG_SIGNING_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - VERSION: ${{ steps.version.outputs.version }} - run: | - echo "Publishing plugins version: $VERSION" - ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository \ - -Pversion=$VERSION \ - -PsonatypeUsername="${{ secrets.MAVEN_USERNAME }}" \ - -PsonatypePassword="${{ secrets.MAVEN_PASSWORD }}" \ - --info - - - name: Enable auto-merge for PR + + - name: Auto-merge PR on successful deployment if: success() - run: | - gh pr merge --squash --auto - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GIT_TOKEN }} + script: | + const pr = context.payload.pull_request; + if (pr) { + await github.rest.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + merge_method: 'merge' + }); + console.log(`PR #${pr.number} has been automatically merged after successful deployment`); + } \ No newline at end of file From bbcb767d18ccb0be27ca68695cb06f19fd9f72e4 Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:17:20 +0900 Subject: [PATCH 08/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 4aea3d3..4944c81 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -60,9 +60,8 @@ jobs: echo "Version: ${{ steps.version.outputs.version }}" - name: Publish package - uses: gradle/gradle-build-action@v2 - with: - arguments: | + run: > + ./gradlew -PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }} -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }} -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }} From dbf5b65cc62938d07cb08c7505b4670f4bbad63c Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:24:50 +0900 Subject: [PATCH 09/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index 4944c81..b41979c 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -62,11 +62,11 @@ jobs: - name: Publish package run: > ./gradlew - -PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }} - -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }} - -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }} - -PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }} - allTests publishAndReleaseToMavenCentral + -PmavenCentralUsername=${{ secrets.MAVEN_USERNAME }} + -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }} + -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }} + -PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }} + allTests publishAndReleaseToMavenCentral env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} From 115d4106af3d376b4f78a05b55da88b0d19cd1b7 Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:26:42 +0900 Subject: [PATCH 10/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .github/workflows/deploy-maven-central.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-maven-central.yml b/.github/workflows/deploy-maven-central.yml index b41979c..b484fbe 100644 --- a/.github/workflows/deploy-maven-central.yml +++ b/.github/workflows/deploy-maven-central.yml @@ -66,7 +66,7 @@ jobs: -PmavenCentralPassword=${{ secrets.MAVEN_PASSWORD }} -PsigningInMemoryKeyId=${{ secrets.MAVEN_GPG_KEY_ID }} -PsigningInMemoryPassword=${{ secrets.MAVEN_GPG_PASSPHRASE }} - allTests publishAndReleaseToMavenCentral + publishAndReleaseToMavenCentral env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} From 7101672b671fd6d466d70f6fcef871f37ba0d55d Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:33:24 +0900 Subject: [PATCH 11/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- build.gradle.kts | 57 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9f0480d..451be9e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,11 +2,53 @@ plugins { kotlin("jvm") version "1.9.0" application id("io.github.gradle-nexus.publish-plugin") version "1.3.0" + id("com.vanniktech.maven.publish") version "0.29.0" } -group = "net.kigawa" -version = "1.0.0" +object Conf { + const val GROUP = "net.kigawa" + // Base version - will be modified based on branch name if available + const val BASE_VERSION = "1.2.1" +} + +// Determine version based on branch name +// Branch naming convention for releases: release/vx.x.x (e.g., release/v1.0.0) +fun determineVersion(): String { + // Try to get branch name from different environment variables + // For pull requests, GITHUB_HEAD_REF contains the source branch name + // For direct pushes, GITHUB_REF_NAME contains the branch name + val branchName = System.getenv("GITHUB_HEAD_REF") + ?: System.getenv("GITHUB_REF_NAME") + ?: return Conf.BASE_VERSION + + // For main branch, use the base version + if (branchName == "main") { + return Conf.BASE_VERSION + } + + // For release branches in format 'release/vx.x.x', use the version from the branch name + val releasePattern = Regex("^release/v(\\d+\\.\\d+\\.\\d+)$") + val matchResult = releasePattern.find(branchName) + if (matchResult != null) { + // Extract version number from branch name + val versionFromBranch = matchResult.groupValues[1] + return versionFromBranch + } + // For other branches, use format: baseVersion-branchName-SNAPSHOT + // Replace any non-alphanumeric characters with dashes for Maven compatibility + val sanitizedBranchName = branchName.replace(Regex("[^a-zA-Z0-9]"), "-") + return "${Conf.BASE_VERSION}-${sanitizedBranchName}-SNAPSHOT" +} + +val projectVersion = determineVersion() + +group = Conf.GROUP +version = projectVersion +allprojects { + group = Conf.GROUP + version = projectVersion +} repositories { mavenCentral() } @@ -23,13 +65,12 @@ kotlin { jvmToolchain(8) } + nexusPublishing { + // Configure maven central repository + // https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh repositories { - sonatype { - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - username.set(System.getenv("MAVEN_USERNAME") ?: project.findProperty("sonatypeUsername") as String?) - password.set(System.getenv("MAVEN_PASSWORD") ?: project.findProperty("sonatypePassword") as String?) - } + sonatype() + } } From 9aa0fcf3b7d7d675ddc5f943ee4d848bfa3f33e0 Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 01:41:29 +0900 Subject: [PATCH 12/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 451be9e..c82e4ea 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") version "1.9.0" + kotlin("jvm") version "2.1.0" application id("io.github.gradle-nexus.publish-plugin") version "1.3.0" id("com.vanniktech.maven.publish") version "0.29.0" From 110a545d4a3b4c67f8e9ae271b21f1866922ab40 Mon Sep 17 00:00:00 2001 From: kigawa Date: Tue, 19 Aug 2025 02:01:56 +0900 Subject: [PATCH 13/13] Remove Gradle wrapper validation step from Maven Central deployment workflow --- .idea/kotlinc.xml | 2 +- build.gradle.kts | 71 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index fdf8d99..bb44937 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index c82e4ea..fbf065b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,17 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { kotlin("jvm") version "2.1.0" application + `maven-publish` + signing id("io.github.gradle-nexus.publish-plugin") version "1.3.0" id("com.vanniktech.maven.publish") version "0.29.0" } object Conf { const val GROUP = "net.kigawa" + // Base version - will be modified based on branch name if available const val BASE_VERSION = "1.2.1" } @@ -66,11 +71,67 @@ kotlin { } -nexusPublishing { - // Configure maven central repository - // https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh - repositories { - sonatype() +publishing { + // Configure all publications + publications.withType { + // disabled https://github.com/vanniktech/gradle-maven-publish-plugin/issues/754 + // and configured at library build.gradle.kts using `JavadocJar.Dokka("dokkaHtml")`. + /* + // Stub javadoc.jar artifact + artifact(tasks.register("${name}JavadocJar", Jar::class) { + archiveClassifier.set("javadoc") + archiveAppendix.set(this@withType.name) + })*/ + + // Provide artifacts information required by Maven Central + pom { + name = "renlin-router" + description = "routing library for renlin" + url = "https://github.com/Code-Sakura/renlin-router" + properties = mapOf( + ) + licenses { + license { + name.set("MIT License") + url.set("http://www.opensource.org/licenses/mit-license.php") + } + } + developers { + developer { + id.set("net.kigawa") + name.set("kigawa") + email.set("contact@kigawa.net") + } + developer { + id.set("io.github.seizavl") + name.set("seizavl") + email.set("") + } + } + scm { + connection.set("scm:git:https://github.com/Code-Sakura/renlin-router.git") + developerConnection.set("scm:git:https://github.com/Code-Sakura/renlin-router.git") + url.set("https://github.com/Code-Sakura/renlin-router") + } + } + } +} +signing { + if (project.hasProperty("mavenCentralUsername") || + System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername") != null + ) { + useGpgCmd() + // It is not perfect (fails at some dependency assertions), better handled as + // `signAllPublications()` (as in vanniktech maven publish plugin) at build.gradle.kts. + //sign(publishing.publications) } } + +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + if (project.hasProperty("mavenCentralUsername") || + System.getenv("ORG_GRADLE_PROJECT_mavenCentralUsername") != null + ) + signAllPublications() +} \ No newline at end of file