diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml new file mode 100644 index 0000000..c2c2159 --- /dev/null +++ b/.forgejo/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Push plugin to maven + +on: + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + - name: Set up JDK + uses: github.com/actions/setup-java@v1 + with: + java-version: 21 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and publish with gradle + run: ./gradlew publish + env: + MAVEN_URL: ${{ secrets.MAVEN_URL }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 2f9ef0d..a0e061c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,10 @@ plugins { id("java") + id("maven-publish") } group = "gay.shorks" -version = "1.0-SNAPSHOT" +version = "1.0.0+kc.24" repositories { mavenCentral() @@ -14,3 +15,24 @@ dependencies { implementation(libs.keycloak.server.spi) implementation(libs.keycloak.services) } + +publishing { + publications.create("maven") { + from(components["java"]) + } + + repositories { + if (System.getenv("MAVEN_URL") != null) { + maven { + name = "ashhhleyyy" + setUrl(System.getenv("MAVEN_URL")) + credentials { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_PASSWORD") + } + } + } else { + mavenLocal() + } + } +}