diff --git a/.github/secret/secret-keys.gpg b/.github/secret/secret-keys.gpg deleted file mode 100644 index e131f7119..000000000 Binary files a/.github/secret/secret-keys.gpg and /dev/null differ diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index c47581860..000000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle - -name: Gradle Build - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@859c33240bd026ce8d5f711f5adcc65c2f8eafc1 - - name: Build with Gradle - run: ./gradlew build - diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 000000000..9b1d2dd05 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,61 @@ +name: Build and Deploy + +on: + push: + branches: [ main ] + tags: + - '*' + + +permissions: + checks: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + checks: write + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 + - name: Build with Gradle + run: ./gradlew build + + - name: Deploy with JReleaser + if: startsWith(github.ref, 'refs/tags/') + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + run: ./gradlew publish jreleaserDeploy + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: JUnit Tests + path: "build/test-results/test/*.xml" + reporter: java-junit + fail-on-error: true + + create-release: + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: true diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 481cf2fb7..000000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle - -name: Gradle Package - -on: - release: - types: [ created ] - -jobs: - build: - - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Build with Gradle - uses: gradle/gradle-build-action@0842a550d10f5211be8c8295f6888889e1fca291 - with: - arguments: build - - - name: Git status - run: git status - # Publishing to Maven Central - - name: Publish to Maven Central - uses: gradle/gradle-build-action@0842a550d10f5211be8c8295f6888889e1fca291 - with: - arguments: printVersion publish closeAndReleaseStagingRepository -Psigning.secretKeyRingFile=./.github/secret/secret-keys.gpg -Psigning.password=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} -Psigning.keyId=${{ secrets.OSSRH_GPG_SECRET_KEY }} - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} - - diff --git a/.github/workflows/pullRequest.yaml b/.github/workflows/pullRequest.yaml new file mode 100644 index 000000000..0ef19b643 --- /dev/null +++ b/.github/workflows/pullRequest.yaml @@ -0,0 +1,38 @@ +name: Pull Request Build + +on: + pull_request: + branches: [ main ] + + +permissions: + checks: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + checks: write + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 + - name: Build with Gradle + run: ./gradlew build + + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: JUnit Tests + path: "build/test-results/test/*.xml" + reporter: java-junit + fail-on-error: true diff --git a/build.gradle b/build.gradle index 02ae87fd7..06f80271b 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.7.20' id 'maven-publish' id 'org.jetbrains.kotlinx.kover' version '0.4.4' - id 'signing' id 'io.github.gradle-nexus.publish-plugin' version "1.1.0" id 'com.palantir.git-version' version '0.15.0' + id 'org.jreleaser' version '1.15.0' } group 'io.github.ludorival' @@ -62,27 +62,7 @@ publishing { } repositories { maven { - name = "OSSRH" - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - credentials { - username = findProperty("maven.username") ?: System.getenv("OSSRH_USERNAME") - password = findProperty("maven.password") ?: System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD") - } - - } - } -} - -signing { - sign publishing.publications.mavenJava -} -nexusPublishing { - repositories { - sonatype { - username = findProperty("maven.username") ?: System.getenv("OSSRH_USERNAME") - password = findProperty("maven.password") ?: System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD") - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + url = uri("$buildDir/staging-deploy") } } } @@ -114,3 +94,25 @@ dependencies { testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' } + +jreleaser { + signing { + active = 'ALWAYS' + armored = true + } + + deploy { + maven { + mavenCentral { + sonatype { + applyMavenCentralRules = true + password = findProperty('maven.password') ?: System.getenv('MAVEN_CENTRAL_PASSWORD') + username = findProperty('maven.username') ?: System.getenv('MAVEN_CENTRAL_USERNAME') + active = 'ALWAYS' + url = 'https://s01.oss.sonatype.org/service/local/' + stagingRepository('build/staging-deploy') + } + } + } + } +}