Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
der-fruhling committed May 22, 2024
1 parent 66345ca commit fe28ecd
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 25 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/gradle-multi-ref.yml
Original file line number Diff line number Diff line change
@@ -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
134 changes: 113 additions & 21 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,137 @@
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:
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

- 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 }}
6 changes: 2 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ name: Java CI with Gradle

on:
push:
branches: [ "master" ]
branches-ignore:
- master
paths-ignore:
- .github/workflows/gradle-publish.yml
- .idea/**
Expand All @@ -18,7 +19,6 @@ on:
- LICENSE
- README.md
pull_request:
branches: [ "master" ]
paths-ignore:
- .github/workflows/gradle-publish.yml
- .idea/**
Expand All @@ -29,7 +29,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -62,7 +61,6 @@ jobs:
# run: gradle build

dependency-submission:

runs-on: ubuntu-latest
permissions:
contents: write
Expand Down

0 comments on commit fe28ecd

Please sign in to comment.