Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/internal.gradle.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "[Gradle] Build project"

on:
workflow_call:
inputs:
image:
description: Which image to run the different tasks on (image must support bash)
type: string
required: true
java:
description: The version of Java to use to run Gradle
type: string
required: true
gradle_build_task:
description: The name of the gradle build task to use
type: string
required: true
version:
description: The version to use during compilation
type: string
required: true
secrets:
GRADLE_ENCRYPTION_KEY:
description: The AES key to enable Gradle cache encryption
required: false

permissions:
contents: read

jobs:
build:
runs-on: ${{ inputs.image }}
steps:
- name: "📦 Checkout"
uses: actions/checkout@v4

- name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041
run: git fetch --tags

- name: "⚙️ Configure Java"
run: echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV"

- name: "⚙️ Configure Gradle"
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_build_task }} -PfullVersion=${{ inputs.version }}
84 changes: 84 additions & 0 deletions .github/workflows/internal.gradle.publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "[Gradle] Publish project to Github/JFrog/CurseForge/Crowdin"

on:
workflow_call:
inputs:
image:
description: Which image to run the different tasks on (image must support bash)
type: string
required: true
java:
description: The version of Java to use to run Gradle
type: string
required: true
version:
description: The version to use during compilation
type: string
required: true
gradle_publish_task:
description: The name of the gradle publish task to use
type: string
required: true
release_type:
description: The type of release to make on Curse, can either be 'beta' or 'release'
type: string
required: false
secrets:
GRADLE_ENCRYPTION_KEY:
description: The AES key to enable Gradle cache encryption
required: false
GITHUB_PUBLISH_USER:
description: The user to use to publish to Github Packages
required: false
GITHUB_PUBLISH_TOKEN:
description: The token to publish to Github Packages
required: false
JFROG_PUBLISH_USER:
description: The user to use to publish to JFrog
required: false
JFROG_PUBLISH_PASSWORD:
description: The password for the user to publish to JFrog
required: false
CURSE_API_KEY:
description: The API key to publish to CurseForge
required: false
CROWDIN_API_KEY:
description: The API key to publish to Crowdin

permissions:
contents: read

jobs:
publish:
runs-on: ${{ inputs.image }}
steps:
- name: "📦 Checkout"
uses: actions/checkout@v4

- name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041
run: git fetch --tags

- name: "⚙️ Configure Java"
run: echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV"

- name: "⚙️ Configure Gradle"
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

- name: "🚀 Publish"
run: ./gradlew --build-cache ${{ inputs.gradle_publish_task }} -PmodVersion=${{ inputs.version }}
env:
# Github
GITHUB_USERNAME: ${{ secrets.GITHUB_PUBLISH_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_PUBLISH_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
# JFrog
LDTTeamJfrogUsername: ${{ secrets.JFROG_PUBLISH_USER }}
LDTTeamJfrogPassword: ${{ secrets.JFROG_PUBLISH_PASSWORD }}
# CurseForge
CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }}
CURSE_RELEASE_TYPE: ${{ inputs.release_type }}
# Crowdin
CROWD_IN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
139 changes: 139 additions & 0 deletions .github/workflows/internal.gradle.version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: "[Gradle] Determine Build Version"

on:
workflow_call:
inputs:
image:
description: Which image to run the different tasks on (image must support bash)
type: string
required: true
version_suffix:
description: The version suffix
type: string
required: true
increment_version:
description: How to increment the version, or none if no version increment is necessary
type: string
required: true
outputs:
minecraft_version:
description: The minecraft version string
value: ${{ jobs.compute-version.outputs.minecraft_version }}
current_mod_version:
description: The current mod version string
value: ${{ jobs.compute-version.outputs.current_mod_version }}
current_tag_version:
description: The current tag version string
value: ${{ jobs.compute-version.outputs.current_tag_version }}
current_full_version:
description: The current full version string
value: ${{ jobs.compute-version.outputs.current_full_version }}
next_tag_version:
description: The next tag version string
value: ${{ jobs.compute-version.outputs.next_tag_version }}
next_mod_version:
description: The next mod version string
value: ${{ jobs.compute-version.outputs.next_mod_version }}
next_full_version:
description: The next full version string
value: ${{ jobs.compute-version.outputs.next_mod_version }}
release_name:
description: The name for the release version
value: ${{ jobs.compute-version.outputs.release_name }}

permissions:
contents: read

jobs:
compute-version:
runs-on: ${{ inputs.image }}
outputs:
minecraft_version: ${{ steps.getMinecraftVersion.outputs.version }}
current_mod_version: ${{ steps.getModVersion.outputs.version }}
current_tag_version: v${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getModVersion.outputs.version }}
current_full_version: ${{ steps.generateFullVersion.outputs.current_full_version }}
next_mod_version: ${{ steps.getNextModVersion.outputs.version }}
next_tag_version: v${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getNextModVersion.outputs.version }}
next_full_version: ${{ steps.generateFullVersion.outputs.next_full_version }}
release_name: ${{ steps.generateReleaseName.outputs.release_name }}
steps:
- name: "📦 Checkout"
uses: actions/checkout@v4

- name: "📦 Fetch tags" # See https://github.com/actions/checkout/issues/2041
run: git fetch --tags

- id: getVersionOrdering
name: "⚙️ Get version ordering"
run: |
uses_mc_version_order_first=$(cat gradle.properties | grep usesMCVersionOrderFirst | cut -d "=" -f 2)
if [ -z "$uses_mc_version_order_first" ]; then
uses_mc_version_order_first=false
fi
echo "Using MC version order first: $uses_mc_version_order_first"
echo "uses_mc_version_order_first=$uses_mc_version_order_first" >> "$GITHUB_OUTPUT"

- id: getMinecraftVersion
name: "⚙️ Generate Minecraft version"
run: |
version=$(cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2)
echo "Minecraft version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- id: getModVersion
name: "⚙️ Get mod version"
run: |
version=$(git describe --abbrev=0 --tags $(git rev-list --tags=${{ github.ref_name }} --max-count=1) | sed s/v${{ steps.getMinecraftVersion.outputs.version }}-//)
echo "Current mod version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- id: generateModVersion
name: "⚙️ Generate next mod version"
uses: cbrgm/semver-bump-action@v1.0.43
if: ${{ inputs.increment_version != 'none'}}
with:
current-version: ${{ steps.getModVersion.outputs.version }}
bump-level: ${{ inputs.increment_version }}

- id: getNextModVersion
name: "⚙️ Get next mod version"
run: |
version=${{ steps.generateModVersion.conclusion != 'skipped' && steps.generateModVersion.outputs.new_version || steps.getModVersion.outputs.version }}
echo "Next mod version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- id: generateFullVersion

- id: generateFullVersion
name: "Generate full version"
run: |
if [[ -n "${{inputs.version_suffix}}" ]]
then
if [ ${{ steps.getVersionOrdering.outputs.uses_mc_version_order_first }} == "true" ]
then
current_full_version="${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getModVersion.outputs.version }}-${{ inputs.version_suffix }}"
next_full_version="${{ steps.getMinecraftVersion.outputs.version }}-${{ steps.getNextModVersion.outputs.version }}-${{ inputs.version_suffix }}"
else
current_full_version="${{ steps.getModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ inputs.version_suffix }}"
next_full_version="${{ steps.getNextModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ inputs.version_suffix }}"
fi
else
if [ ${{ steps.getVersionOrdering.outputs.uses_mc_version_order_first }} == "true" ]
then
current_full_version="${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ steps.getModVersion.outputs.version }}"
next_full_version="${{ steps.getMinecraftVersion.outputs.minecraft_version }}-${{ steps.getNextModVersion.outputs.version }}"
else
current_full_version="${{ steps.getModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}"
next_full_version="${{ steps.getNextModVersion.outputs.version }}-${{ steps.getMinecraftVersion.outputs.minecraft_version }}"
fi
fi
echo "Current full version: ${next_full_version}"
echo "Next full version: ${next_full_version}"
echo "current_full_version=${current_full_version}" >> "$GITHUB_OUTPUT"
echo "next_full_version=${next_full_version}" >> "$GITHUB_OUTPUT"

- id: generateReleaseName
name: "⚙️ Generate release name"
run: |
release_name="Version ${{ steps.getNextModVersion.outputs.version }} for Minecraft ${{ steps.getMinecraftVersion.outputs.version }}"
echo "Release name: $release_name"
echo "release_name=$release_name" >> "$GITHUB_OUTPUT"
85 changes: 85 additions & 0 deletions .github/workflows/project.build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: "[Project] Build project & pre-release"

on:
workflow_call:
inputs:
image:
description: Which image to run the different tasks on (image must support bash)
type: string
required: false
default: ubuntu-latest
java:
description: The version of Java to use to run Gradle
type: string
required: false
default: "21"
version_suffix:
description: The suffix to put behind the branch, defaults to the pull request number. If not a pull request you must define this by hand.
type: string
required: false
default: ${{ github.event.number }}
create_prerelease:
description: Whether to make a prerelease version or not
type: boolean
required: false
default: false
gradle_build_task:
description: The name of the gradle build task to use
type: string
required: false
default: build
gradle_publish_task:
description: The name of the gradle publish task to use
type: string
required: false
default: publish
secrets:
GRADLE_ENCRYPTION_KEY:
description: The AES key to enable Gradle cache encryption
required: false

permissions:
contents: read

jobs:
validate-inputs:
runs-on: ${{ inputs.image }}
if: |
(inputs.image == '') ||
(inputs.java <= 0) ||
(inputs.version_suffix == '') ||
(inputs.gradle_build_task == '') &&
(inputs.gradle_publish_task == '')
steps:
- run: exit 1

compute-version:
uses: ./.github/workflows/internal.gradle.version.yaml
with:
image: ${{ inputs.image }}
version_suffix: ${{ inputs.version_suffix }}-rc
increment_version: ${{ inputs.create_prerelease && 'prepatch' || 'none' }}
secrets: inherit

build:
needs:
- compute-version
uses: ./.github/workflows/internal.gradle.build.yaml
with:
image: ${{ inputs.image }}
java: ${{ inputs.java }}
gradle_build_task: ${{ inputs.gradle_build_task }}
version: ${{ needs.compute-version.outputs.next_full_version }}
secrets: inherit

pre-release:
needs:
- compute-version
if: ${{ inputs.create_prerelease }}
uses: ./.github/workflows/internal.gradle.publish.yaml
with:
image: ${{ inputs.image }}
java: ${{ inputs.java }}
gradle_publish_task: ${{ inputs.gradle_publish_task }}
version: ${{ needs.compute-version.outputs.next_full_version }}
secrets: inherit
Loading