From 5345733e38c71b048cdd708b6052e34715bf1990 Mon Sep 17 00:00:00 2001 From: Antoine Belvire Date: Tue, 26 Nov 2024 23:16:25 +0100 Subject: [PATCH 1/4] chore: Publish to GitHub Packages --- .github/workflows/gradle.yml | 12 ++++++++++++ build.gradle.kts | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e2a60b7..7fa04f7 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,3 +28,15 @@ jobs: - name: Build with Gradle run: gradle build + + publish: + runs-on: ubuntu-latest + needs: build + permissions: + contents: read + packages: write + steps: + - 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 From 6d49e9a3c004b4c3c7da1d5c25c8b71918725ac0 Mon Sep 17 00:00:00 2001 From: Antoine Belvire Date: Thu, 28 Nov 2024 07:20:07 +0100 Subject: [PATCH 2/4] chore: Fix workflow --- .github/workflows/gradle.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 7fa04f7..9997579 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -36,6 +36,15 @@ jobs: contents: read packages: write steps: + - 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: From 4f84891f0835630ef48e3249d682c7d298e023c3 Mon Sep 17 00:00:00 2001 From: Antoine Belvire Date: Thu, 28 Nov 2024 07:22:00 +0100 Subject: [PATCH 3/4] chore: Fix workflow again --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 9997579..0f40281 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -36,6 +36,7 @@ jobs: contents: read packages: write steps: + - uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: From e3593ba860ea8d13668b5eb7f9c243d15f3188e3 Mon Sep 17 00:00:00 2001 From: Antoine Belvire Date: Thu, 28 Nov 2024 07:32:06 +0100 Subject: [PATCH 4/4] chore: Don't publish non-main branch --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 0f40281..42c283a 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,6 +30,7 @@ jobs: run: gradle build publish: + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: build permissions: