From ab23db7d1a886f3390938d4afa00cc0003ccb231 Mon Sep 17 00:00:00 2001 From: Scarlet Pan Date: Sun, 16 Nov 2025 19:10:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?project=20=E5=8F=91=E5=B8=83=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 26 ++++++++++ .../workflows/publish_to_maven_central.yml | 28 +++++++++++ .github/workflows/test.yml | 42 ++++++++++++++++ gradle/libs.versions.toml | 9 ++-- jitpack.yml | 4 -- try-catch/build.gradle.kts | 50 +++++++++++++++---- 6 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/publish_to_maven_central.yml create mode 100644 .github/workflows/test.yml delete mode 100644 jitpack.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fc7d835 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish +on: + release: + types: [released, prereleased] +jobs: + publish: + name: Release build and publish + runs-on: macOS-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 21 + + - name: Publish to MavenCentral + run: ./gradlew publishToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/publish_to_maven_central.yml b/.github/workflows/publish_to_maven_central.yml new file mode 100644 index 0000000..8acd4ff --- /dev/null +++ b/.github/workflows/publish_to_maven_central.yml @@ -0,0 +1,28 @@ +name: Publish to Maven Central + +on: + workflow_dispatch: + +jobs: + publish: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Publish to Maven Central + run: ./gradlew publishAllPublicationsToMavenCentralRepository + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..00d1002 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Make gradlew executable (if needed) + run: chmod +x ./gradlew + + - name: Run tests + run: ./gradlew check --continue + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-reports + path: | + logger/build/reports/tests/** + logger/build/test-results/** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6c27328..b285d4a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,9 @@ [versions] -agp = "8.7.3" kotlin = "1.9.24" -kotlinJvm = "1.9.24" +kotlin-runtime = "1.9.24" +agp = "8.7.3" +publish = "0.34.0" + junit = "4.13.2" jetbrainsKotlinJvm = "1.9.24" @@ -13,4 +15,5 @@ junit = { group = "junit", name = "junit", version.ref = "junit" } android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "jetbrainsKotlinJvm" } -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinJvm" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-runtime" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index 9ff8d72..0000000 --- a/jitpack.yml +++ /dev/null @@ -1,4 +0,0 @@ -jdk: - - openjdk17 -install: - - ./gradlew publishToMavenLocal \ No newline at end of file diff --git a/try-catch/build.gradle.kts b/try-catch/build.gradle.kts index a1a55f9..14b8f47 100644 --- a/try-catch/build.gradle.kts +++ b/try-catch/build.gradle.kts @@ -3,9 +3,13 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id("java-library") alias(libs.plugins.kotlin.jvm) - `maven-publish` + alias(libs.plugins.maven.publish) + signing } +group = "io.github.scarlet-pan" +version = "1.0.0-SNAPSHOT" + java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 @@ -25,16 +29,44 @@ dependencies { testImplementation(libs.junit) } -publishing { - publications { - create("maven") { - groupId = "com.github.Scarlet-Pan" - artifactId = "try-catch" - version = "1.0.0" +mavenPublishing { + publishToMavenCentral() + + signAllPublications() - afterEvaluate { - from(components["kotlin"]) + coordinates(group.toString(), "try-catch", version.toString()) + + pom { + name = "try-catch" + description = "A coroutine-friendly, type-safe try-catch-style wrapper for handling exception." + inceptionYear = "2025" + url = "https://github.com/scarlet-pan/try-catch" + licenses { + license { + name = "MIT License" + url = "https://opensource.org/licenses/MIT" + } + } + developers { + developer { + id = "Scarlet-Pan" + name = "Scarlet Pan" + email = "scarletpan@qq.com" } } + scm { + url = "https://github.com/scarlet-pan/try-catch" + connection = "scm:git:https://github.com/scarlet-pan/try-catch.git" + developerConnection = "scm:git:ssh://git@github.com/scarlet-pan/try-catch.git" + } } +} + +signing { + useInMemoryPgpKeys( + providers.gradleProperty("signingInMemoryKeyId").orNull, + providers.gradleProperty("signingInMemoryKey").orNull, + providers.gradleProperty("signingInMemoryKeyPassword").orNull + ) + sign(publishing.publications) } \ No newline at end of file From 9a5b48a86db9f831b31b8a97568a4f14d86acdb4 Mon Sep 17 00:00:00 2001 From: Scarlet Pan Date: Sun, 16 Nov 2025 19:10:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?project=20=E5=8F=91=E5=B8=83=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 26 ++++++++++ .../workflows/publish_to_maven_central.yml | 28 +++++++++++ .github/workflows/test.yml | 42 ++++++++++++++++ gradle/libs.versions.toml | 11 +++- jitpack.yml | 4 -- try-catch/build.gradle.kts | 50 +++++++++++++++---- 6 files changed, 146 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/publish_to_maven_central.yml create mode 100644 .github/workflows/test.yml delete mode 100644 jitpack.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..fc7d835 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish +on: + release: + types: [released, prereleased] +jobs: + publish: + name: Release build and publish + runs-on: macOS-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 21 + + - name: Publish to MavenCentral + run: ./gradlew publishToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/publish_to_maven_central.yml b/.github/workflows/publish_to_maven_central.yml new file mode 100644 index 0000000..8acd4ff --- /dev/null +++ b/.github/workflows/publish_to_maven_central.yml @@ -0,0 +1,28 @@ +name: Publish to Maven Central + +on: + workflow_dispatch: + +jobs: + publish: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Publish to Maven Central + run: ./gradlew publishAllPublicationsToMavenCentralRepository + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..00d1002 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Make gradlew executable (if needed) + run: chmod +x ./gradlew + + - name: Run tests + run: ./gradlew check --continue + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-reports + path: | + logger/build/reports/tests/** + logger/build/test-results/** diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d2aca1d..3715e8a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,9 @@ [versions] -kotlinJvm = "1.9.24" +kotlin = "1.9.24" +kotlin-runtime = "1.9.24" +agp = "8.7.3" +publish = "0.34.0" + junit = "4.13.2" [libraries] @@ -7,4 +11,7 @@ kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor junit = { group = "junit", name = "junit", version.ref = "junit" } [plugins] -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinJvm" } +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-runtime" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/jitpack.yml b/jitpack.yml deleted file mode 100644 index 9ff8d72..0000000 --- a/jitpack.yml +++ /dev/null @@ -1,4 +0,0 @@ -jdk: - - openjdk17 -install: - - ./gradlew publishToMavenLocal \ No newline at end of file diff --git a/try-catch/build.gradle.kts b/try-catch/build.gradle.kts index a1a55f9..14b8f47 100644 --- a/try-catch/build.gradle.kts +++ b/try-catch/build.gradle.kts @@ -3,9 +3,13 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id("java-library") alias(libs.plugins.kotlin.jvm) - `maven-publish` + alias(libs.plugins.maven.publish) + signing } +group = "io.github.scarlet-pan" +version = "1.0.0-SNAPSHOT" + java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 @@ -25,16 +29,44 @@ dependencies { testImplementation(libs.junit) } -publishing { - publications { - create("maven") { - groupId = "com.github.Scarlet-Pan" - artifactId = "try-catch" - version = "1.0.0" +mavenPublishing { + publishToMavenCentral() + + signAllPublications() - afterEvaluate { - from(components["kotlin"]) + coordinates(group.toString(), "try-catch", version.toString()) + + pom { + name = "try-catch" + description = "A coroutine-friendly, type-safe try-catch-style wrapper for handling exception." + inceptionYear = "2025" + url = "https://github.com/scarlet-pan/try-catch" + licenses { + license { + name = "MIT License" + url = "https://opensource.org/licenses/MIT" + } + } + developers { + developer { + id = "Scarlet-Pan" + name = "Scarlet Pan" + email = "scarletpan@qq.com" } } + scm { + url = "https://github.com/scarlet-pan/try-catch" + connection = "scm:git:https://github.com/scarlet-pan/try-catch.git" + developerConnection = "scm:git:ssh://git@github.com/scarlet-pan/try-catch.git" + } } +} + +signing { + useInMemoryPgpKeys( + providers.gradleProperty("signingInMemoryKeyId").orNull, + providers.gradleProperty("signingInMemoryKey").orNull, + providers.gradleProperty("signingInMemoryKeyPassword").orNull + ) + sign(publishing.publications) } \ No newline at end of file From d7335fb9e4ec0fdf5e938336be9eef410c56dc57 Mon Sep 17 00:00:00 2001 From: Scarlet Pan Date: Sun, 16 Nov 2025 20:11:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?project=20=E5=B7=A5=E7=A8=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle/libs.versions.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3715e8a..4d8f1fc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,5 @@ [versions] kotlin = "1.9.24" -kotlin-runtime = "1.9.24" -agp = "8.7.3" publish = "0.34.0" junit = "4.13.2" @@ -11,7 +9,5 @@ kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-cor junit = { group = "junit", name = "junit", version.ref = "junit" } [plugins] -android-application = { id = "com.android.application", version.ref = "agp" } -kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin-runtime" } +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" }