From b359ec964c98e53662ff435d3b91587e09a7b764 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Thu, 28 Jul 2022 23:33:33 +0200 Subject: [PATCH] Add github-packages publishing --- .github/workflows/gradle.yml | 4 ++-- .github/workflows/publish.yml | 22 ++++++++++++++++++++++ build.gradle.kts | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 3cac494..3575d27 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -6,7 +6,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 with: submodules: recursive - name: Set up Java 11 @@ -14,7 +14,7 @@ jobs: with: java-version: 11 - name: Build with Gradle - run: ./gradlew build + run: ./gradlew clean build test - uses: actions/upload-artifact@v2-preview with: name: artifact diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..a19488c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,22 @@ +name: Java CI + +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up Java 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Build with Gradle + env: + GITHUB_USERNAME: ${{ secrets.github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./gradlew clean build test publish diff --git a/build.gradle.kts b/build.gradle.kts index 6f49f71..89b2c07 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import java.io.IOException plugins { java `java-library` + `maven-publish` id("com.diffplug.spotless") version "6.1.2" } @@ -88,3 +89,23 @@ tasks.processResources { ) } } + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/BlueMap-Minecraft/BlueMapAPI") + credentials { + username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") + } + } + } + + publications { + register("gpr") { + from(components["java"]) + artifactId = "BlueMapAPI" + } + } +}