From a7e91549875559d25a8b126ac6a8acdb345c48ce Mon Sep 17 00:00:00 2001 From: shartte Date: Thu, 27 Jun 2024 04:47:20 +0200 Subject: [PATCH] Make Release Workflow use Maven Publish Action (#7977) (cherry picked from commit 9d1bcddae13e43190bae89e49de6c44425cc679d) --- .github/workflows/release.yml | 35 ++++++++++++++++++----------------- build.gradle | 16 ++-------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dee6d04afb9..83d81ade99a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,9 +21,7 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/gradle-setup - name: Build with Gradle - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build -x check --no-daemon --max-workers 1 + run: ./gradlew build publish -x check --no-daemon --max-workers 1 - name: Prepare artifact metadata. Note that VERSION is set by the gradle script. id: prepare_artifact_metadata run: | @@ -36,7 +34,7 @@ jobs: echo VERSION=${VERSION} >> $GITHUB_OUTPUT - name: Archive build results # It is important to archive .gradle as well since gradle stores the incremental build state there - run: tar -I zstd -cf build.tar.zst .gradle build src/generated + run: tar -I zstd -cf build.tar.zst build/libs build/repo - name: Upload build and gradle folders uses: actions/upload-artifact@v3 with: @@ -88,9 +86,9 @@ jobs: name: Deploy to Github Packages needs: build runs-on: ubuntu-latest + permissions: + packages: write steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/gradle-setup - name: Download build artifact uses: actions/download-artifact@v3 with: @@ -98,11 +96,14 @@ jobs: - name: Unpack build artifact run: tar axf build.tar.zst - name: Validate artifacts exist - run: test -d ./build && test -d ./.gradle + run: test -d ./build - name: Publish to Github Packages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew publishMavenPublicationToGitHubPackagesRepository --no-daemon --max-workers 1 + uses: AppliedEnergistics/maven-publish-action@main + with: + local-repository-path: build/repo + remote-repository-url: https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2/ + remote-repository-username: ${{ github.actor }} + remote-repository-password: ${{ github.token }} deploy-curseforge: name: Deploy to Curseforge @@ -141,8 +142,6 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/gradle-setup - name: Download build artifact uses: actions/download-artifact@v3 with: @@ -150,12 +149,14 @@ jobs: - name: Unpack build artifact run: tar axf build.tar.zst - name: Validate artifacts exist - run: test -d ./build && test -d ./.gradle + run: test -d ./build - name: Publish to Modmaven - env: - MODMAVEN_USER: ${{ secrets.MODMAVEN_USER }} - MODMAVEN_PASSWORD: ${{ secrets.MODMAVEN_PASSWORD }} - run: ./gradlew publishMavenPublicationToModmavenRepository --no-daemon --max-workers 1 + uses: AppliedEnergistics/maven-publish-action@main + with: + local-repository-path: build/repo + remote-repository-url: https://modmaven.dev/artifactory/local-releases/ + remote-repository-username: ${{ secrets.MODMAVEN_USER }} + remote-repository-password: ${{ secrets.MODMAVEN_PASSWORD }} deploy-modrinth: name: Deploy to Modrinth diff --git a/build.gradle b/build.gradle index 3523795cc69..72226722249 100644 --- a/build.gradle +++ b/build.gradle @@ -492,20 +492,8 @@ publishing { } repositories { maven { - credentials { - username System.getenv("GITHUB_ACTOR") - password System.getenv("GITHUB_TOKEN") - } - name = "GitHubPackages" - url = "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2" - } - maven { - credentials { - username System.getenv("MODMAVEN_USER") - password System.getenv("MODMAVEN_PASSWORD") - } - name = "modmaven" - url = "https://modmaven.dev/artifactory/local-releases/" + name = "Local" + url = file("build/repo").toURI() } } }