diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e2a60b7..42c283a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,3 +28,26 @@ jobs: - name: Build with Gradle run: gradle build + + publish: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: build + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1 + with: + gradle-version: '8.11.1' + - name: Publish package + run: gradle publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 6133907..57248d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { java + `maven-publish` } group = "re.belv" @@ -16,6 +17,28 @@ dependencies { testImplementation("org.assertj:assertj-core:3.26.3") } +java { + withSourcesJar() +} + +publishing { + publications { + register("eternity2Solver") { + from(components["java"]) + } + } + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/super7ramp/eternity2-solver") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + } +} + tasks.test { useJUnitPlatform() } \ No newline at end of file