From a85481a0123121808437a3a38ba8a018ff961e96 Mon Sep 17 00:00:00 2001 From: stashymane Date: Tue, 19 Mar 2024 13:51:22 +0200 Subject: [PATCH] Setup publishing actions --- .github/workflows/gradle.yml | 38 ++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++++ build.gradle.kts | 21 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..09da278 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,38 @@ +# 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. +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'temurin' + - name: Fix Gradle permissions + run: chmod +x ./gradlew + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..46f41da --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Publish release to repositories + +on: + push: + tags: + - "*" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'temurin' + + - name: Make gradlew executable + if: runner.os == 'Linux' + run: chmod +x ./gradlew + + - name: Publish on Maven repository + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: publish + env: + ORG_GRADLE_PROJECT_repoUser: ${{ secrets.REPO_USER }} + ORG_GRADLE_PROJECT_repoToken: ${{ secrets.REPO_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 9b32607..db9eccb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlinx.serialization) + id("maven-publish") } group = "dev.stashy" @@ -22,4 +23,24 @@ tasks.test { kotlin { jvmToolchain(21) +} + +publishing { + publications { + create("mavenJava") { + from(components["java"]) + } + } + + repositories { + maven("https://repo.stashy.dev/releases") { + credentials { + val repoUser: String? by project + val repoToken: String? by project + + username = repoUser ?: "" + password = repoToken ?: "" + } + } + } } \ No newline at end of file