Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 28 additions & 0 deletions .github/workflows/publish_to_maven_central.yml
Original file line number Diff line number Diff line change
@@ -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 }}
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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/**
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[versions]
kotlinJvm = "1.9.24"
kotlin = "1.9.24"
publish = "0.34.0"

junit = "4.13.2"

[libraries]
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.6.4" }
junit = { group = "junit", name = "junit", version.ref = "junit" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinJvm" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" }
4 changes: 0 additions & 4 deletions jitpack.yml

This file was deleted.

50 changes: 41 additions & 9 deletions try-catch/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,16 +29,44 @@ dependencies {
testImplementation(libs.junit)
}

publishing {
publications {
create<MavenPublication>("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)
}
Loading