From fe28ecdfff74716669fccf7bea0b6a8021fef9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?der=5Ffr=C3=BChling?= Date: Tue, 21 May 2024 18:13:28 -0700 Subject: [PATCH] Update workflows --- .github/workflows/gradle-multi-ref.yml | 83 +++++++++++++++ .github/workflows/gradle-publish.yml | 134 +++++++++++++++++++++---- .github/workflows/gradle.yml | 6 +- 3 files changed, 198 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/gradle-multi-ref.yml diff --git a/.github/workflows/gradle-multi-ref.yml b/.github/workflows/gradle-multi-ref.yml new file mode 100644 index 0000000..46110c9 --- /dev/null +++ b/.github/workflows/gradle-multi-ref.yml @@ -0,0 +1,83 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: + - master + paths-ignore: + - .github/workflows/gradle-publish.yml + - .idea/** + - .gitignore + - changelog.md + - LICENSE + - README.md + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + + strategy: + matrix: + branch: [master, port-1.19.2] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + # with: + # gradle-version: '8.5' + # + # - name: Build with Gradle 8.5 + # run: gradle build + + dependency-submission: + runs-on: ubuntu-latest + permissions: + contents: write + + strategy: + matrix: + branch: [master, port-1.19.2] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index ac417b0..543b3d3 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -8,22 +8,38 @@ name: Gradle Package on: - release: - types: [created] + workflow_dispatch: + inputs: + version: + description: The version to publish + required: true + master-ref: + default: "master" + description: The 1.20.1 version of the mod + required: true + port-19-ref: + default: "port-1.19.2" + description: The 1.19.2 version of the mod + required: true jobs: build: - runs-on: ubuntu-latest - environment: - name: Modrinth - url: https://modrinth.com/mod/create-train-perspective permissions: contents: read - packages: write + + strategy: + matrix: + include: + - branch: ${{ inputs.master-ref }} + version: 1.20.1 + - branch: ${{ inputs.port-19-ref }} + version: 1.19.2 steps: - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} - name: Set up JDK 17 uses: actions/setup-java@v4 with: @@ -31,22 +47,98 @@ jobs: distribution: 'temurin' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: Setup Gradle uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 - - name: Build with Gradle run: ./gradlew build + - name: Upload Forge artifact + uses: actions/upload-artifact@v4 + with: + name: create-train-perspective-${{ inputs.version }}-forge${{ matrix.version }}.jar + path: forge/build/libs/create-train-perspective-0.4.0.jar + if-no-files-found: error + compression: 0 + overwrite: true + - name: Upload Fabric artifact + uses: actions/upload-artifact@v4 + with: + name: create-train-perspective-${{ inputs.version }}-fabric${{ matrix.version }}.jar + path: fabric/build/libs/create-train-perspective-0.4.0.jar + if-no-files-found: error + compression: 0 + overwrite: true + + publish-ghp: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + needs: build + strategy: + matrix: + include: + - branch: ${{ inputs.master-ref }} + version: 1.20.1 + - branch: ${{ inputs.port-19-ref }} + version: 1.19.2 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in + # the publishing section of your build.gradle + - name: Publish to GitHub Packages + run: ./gradlew publish + env: + USERNAME: ${{ github.actor }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-modrinth: + runs-on: ubuntu-latest + environment: + name: Modrinth + url: https://modrinth.com/mod/create-train-perspective + permissions: + contents: read + needs: build + strategy: + matrix: + include: + - branch: ${{ inputs.master-ref }} + loader: forge + - branch: ${{ inputs.master-ref }} + loader: fabric + - branch: ${{ inputs.port-19-ref }} + loader: forge + - branch: ${{ inputs.port-19-ref }} + loader: fabric + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 - # The USERNAME and TOKEN need to correspond to the credentials environment variables used in - # the publishing section of your build.gradle - - name: Publish to GitHub Packages - run: ./gradlew publish - env: - USERNAME: ${{ github.actor }} - TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish to Modrinth - run: ./gradlew modrinth - env: - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in + # the publishing section of your build.gradle + - name: Publish to GitHub Packages + run: ./gradlew :${{ matrix.loader }}:modrinth + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d88d07f..4389c12 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,7 +9,8 @@ name: Java CI with Gradle on: push: - branches: [ "master" ] + branches-ignore: + - master paths-ignore: - .github/workflows/gradle-publish.yml - .idea/** @@ -18,7 +19,6 @@ on: - LICENSE - README.md pull_request: - branches: [ "master" ] paths-ignore: - .github/workflows/gradle-publish.yml - .idea/** @@ -29,7 +29,6 @@ on: jobs: build: - runs-on: ubuntu-latest permissions: contents: read @@ -62,7 +61,6 @@ jobs: # run: gradle build dependency-submission: - runs-on: ubuntu-latest permissions: contents: write