From d8cebc02f5c1aa83ad20c921eeb9b5f1b5dfcbfd Mon Sep 17 00:00:00 2001 From: theJawnnybot Date: Thu, 5 Mar 2026 17:02:02 -0600 Subject: [PATCH] build: add Maven Central release workflow and modernize Gradle --- .github/workflows/ci.yml | 24 +++++++++++--- .github/workflows/publish-release.yml | 36 +++++++++++++++++++++ README.md | 10 +++++- build.gradle | 41 +++++++++++++++--------- gradle.properties | 25 +++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/publish-release.yml create mode 100644 gradle.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 170f790..ea7e0e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,26 @@ name: Build -on: [pull_request, push] + +on: + push: + pull_request: + jobs: build: runs-on: ubuntu-latest + steps: - - name: Checkout the code - uses: actions/checkout@v2 - - name: Build the app + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure JDK + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: '17' + cache: gradle + + - name: Validate Gradle Wrapper + uses: gradle/actions/wrapper-validation@v4 + + - name: Build run: ./gradlew build diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..db4be5f --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,36 @@ +name: Publish Release + +on: + push: + tags: + - '*' + +env: + RELEASE_SIGNING_ENABLED: true + +jobs: + publish: + runs-on: ubuntu-latest + if: github.repository == 'Commit451/okyo' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install JDK + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: '17' + cache: gradle + + - name: Set version + run: sed -i "s/VERSION_NAME=1.0.0/VERSION_NAME=$GITHUB_REF_NAME/" gradle.properties + + - name: Release to Maven Central + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} diff --git a/README.md b/README.md index a8eafd3..ac47117 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ [okio](https://github.com/square/okio) made easy, yo -[![](https://jitpack.io/v/Commit451/okyo.svg)](https://jitpack.io/#Commit451/okyo) +[![Maven Central](https://img.shields.io/maven-central/v/com.commit451/okyo.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.commit451/okyo) + +## Gradle + +```kotlin +dependencies { + implementation("com.commit451:okyo:VERSION") +} +``` # Usefulness diff --git a/build.gradle b/build.gradle index e910c1f..099ffa8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,32 +1,41 @@ -buildscript { - ext.kotlin_version = '1.8.22' +import com.vanniktech.maven.publish.SonatypeHost - repositories { - mavenCentral() - } - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } +plugins { + id 'java-library' + id 'org.jetbrains.kotlin.jvm' version '2.1.10' + id 'com.vanniktech.maven.publish' version '0.30.0' } -group 'com.commit451.okyo' -version '1.0.0' - -apply plugin: 'java-library' -apply plugin: 'kotlin' +group = findProperty("GROUP") +version = findProperty("VERSION_NAME") java { toolchain { - languageVersion.set(JavaLanguageVersion.of(8)) + languageVersion = JavaLanguageVersion.of(17) } } +kotlin { + jvmToolchain(17) +} + repositories { mavenCentral() } dependencies { - api("com.squareup.okio:okio:3.5.0") + api("com.squareup.okio:okio:3.10.2") - testImplementation 'junit:junit:4.13.1' + testImplementation("junit:junit:4.13.2") +} + +tasks.withType(Test).configureEach { + useJUnit() +} + +mavenPublishing { + publishToMavenCentral(SonatypeHost.S01) + if (System.getenv("RELEASE_SIGNING_ENABLED") == "true") { + signAllPublications() + } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c4189c9 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,25 @@ +GROUP=com.commit451 +POM_ARTIFACT_ID=okyo +POM_PACKAGING=jar + +POM_NAME=okyo +POM_DESCRIPTION=okio made easy, yo +POM_INCEPTION_YEAR=2017 +POM_URL=https://github.com/Commit451/okyo/ + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_DIST=repo + +POM_SCM_URL=https://github.com/Commit451/okyo/ +POM_SCM_CONNECTION=scm:git:git://github.com/Commit451/okyo/.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/Commit451/okyo/.git + +POM_DEVELOPER_ID=Commit451 +POM_DEVELOPER_NAME=Commit 451 +POM_DEVELOPER_URL=https://github.com/Commit451/ + +SONATYPE_CONNECT_TIMEOUT_SECONDS=60 +SONATYPE_CLOSE_TIMEOUT_SECONDS=900 + +VERSION_NAME=1.0.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 826e2b6..c0cb293 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME