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
65 changes: 38 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,29 @@ on:
type: string
required: false
default: ''
# [FEATURE] MIXIN_AUDITOR
mixin_audit:
description: run mixin audit for Minecraft after build
type: boolean
required: false
default: false
# # [FEATURE] MIXIN_AUDITOR
# mixin_audit:
# description: run mixin audit for Minecraft after build
# type: boolean
# required: false
# default: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
- uses: actions/checkout@v6
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 21
java-version: 25

- name: Cache gradle files
uses: actions/cache@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
./.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener', 'settings.json') }}
restore-keys: |
${{ runner.os }}-gradle-
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev' }}

- name: Build with gradle
run: |
Expand All @@ -57,7 +51,7 @@ jobs:
BUILD_ID: ${{ github.run_number }}
BUILD_RELEASE: ${{ inputs.release }}

# [FEATURE] MIXIN_AUDITOR
# # [FEATURE] MIXIN_AUDITOR
# - name: Run mixin audit check for Minecraft client
# if: ${{ inputs.mixin_audit }}
# timeout-minutes: 10
Expand All @@ -67,7 +61,7 @@ jobs:
# ./gradlew runClientMixinAudit

- name: Upload artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: build-artifacts
path: versions/*/build/libs/
Expand All @@ -83,15 +77,19 @@ jobs:

# This is the artifact recommended for users to download
- name: Upload mod jars
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: mod-jars
path: mod-jars/*.jar

# # [FEATURE] FALLENS_MAVEN
# - name: Publish with gradle
# if: inputs.release || github.ref == 'refs/heads/dev'
# if: ${{ inputs.release || github.ref == 'refs/heads/dev' }}
# run: |
# if [ -z "$FALLENS_MAVEN_TOKEN" ]; then
# echo "No token found, skipping publish"
# exit 0
# fi
# if [ -z "${{ inputs.target_subproject }}" ]; then
# echo "Publishing all subprojects"
# ./gradlew publish
Expand All @@ -111,13 +109,25 @@ jobs:
- build

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.14

- name: List artifacts
uses: actions/github-script@v8
id: artifacts
with:
python-version: 3.12
script: |
const result = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
})
return result.data

- name: Download build artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
name: build-artifacts
path: build-artifacts
Expand All @@ -128,3 +138,4 @@ jobs:
python .github/workflows/scripts/summary.py
env:
TARGET_SUBPROJECT: ${{ inputs.target_subproject }}
WORKFLOW_ARTIFACTS: ${{ steps.artifacts.outputs.result }}
6 changes: 3 additions & 3 deletions .github/workflows/matrix_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
matrix_prep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.12
python-version: 3.14

- id: setmatrix
run: python .github/workflows/scripts/matrix.py
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get github release information
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: cardinalby/git-get-release-action@1.2.5
env:
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -69,16 +68,18 @@ jobs:
- build
runs-on: ubuntu-latest

# allow the mod publish step to add asserts to release
# allow the mod publish step to add assets to release
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions:
contents: write

strategy:
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
fail-fast: false
max-parallel: 4

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Display context
run: |
Expand All @@ -87,13 +88,12 @@ jobs:
echo target_release_tag = ${{ github.event.inputs.target_release_tag }}

- name: Download build artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
name: build-artifacts
path: build-artifacts

- name: Get github release information
if: ${{ github.event_name == 'workflow_dispatch' }}
id: get_release
uses: cardinalby/git-get-release-action@1.2.5
env:
Expand Down Expand Up @@ -150,14 +150,14 @@ jobs:
cat $GITHUB_OUTPUT

- name: Prepare changelog
uses: actions/github-script@v7
uses: actions/github-script@v8
id: changelog
with:
script: return process.env.CHANGELOG
result-encoding: string
env:
CHANGELOG: |-
${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }}
${{ steps.get_release.outputs.body }}

-------

Expand All @@ -168,7 +168,7 @@ jobs:
- Built from: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

- name: Publish Minecraft Mods
uses: Kir-Antipov/mc-publish@v3.3
uses: Kira-NT/mc-publish@v3.3
with:
# https://modrinth.com/settings/pats
# modrinth-id: fo0Bar
Expand All @@ -192,7 +192,7 @@ jobs:
game-version-filter: any
dependencies: '' # declare the dependencies explicitly, so mc-publish won't try to load from fabric.mod.json

github-changelog: ${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }}
github-changelog: ${{ steps.get_release.outputs.body }}
modrinth-changelog: ${{ steps.changelog.outputs.result }}
curseforge-changelog: ${{ steps.changelog.outputs.result }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def main():
target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '')
target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else []))
target_subprojects = [x for x in target_subproject_env.split(',') if x]
print('target_subprojects: {}'.format(target_subprojects))

with open('settings.json') as f:
Expand Down
54 changes: 45 additions & 9 deletions .github/workflows/scripts/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,36 @@ def get_sha256_hash(file_path: str) -> str:


def main():
target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '')
target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else []))
warnings: list[str] = []

target_subproject_env: str = os.environ.get('TARGET_SUBPROJECT', '')
target_subprojects: list[str] = [x for x in target_subproject_env.split(',') if x]
print('target_subprojects: {}'.format(target_subprojects))

workflow_artifacts_json_str = os.environ.get('WORKFLOW_ARTIFACTS', '{"artifacts":[]}')
artifacts: dict[str, dict] = {}
try:
artifacts = {artifact['name']: artifact for artifact in json.loads(workflow_artifacts_json_str)['artifacts']}
print({artifact['name']: artifact['id'] for artifact in artifacts.values()})
except Exception as e:
warnings.append(f'Failed to parse workflow artifacts JSON: {e}, {workflow_artifacts_json_str!r}')

with open('settings.json') as f:
settings: dict = json.load(f)

with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f:
f.write('## Build Artifacts Summary\n\n')
f.write('| Subproject | for Minecraft | File | Size | SHA-256 |\n')
f.write('| Subproject | For Minecraft | File | Size | SHA-256 |\n')
f.write('| --- | --- | --- | --- | --- |\n')

warnings = []
for subproject in settings['versions']:
if len(target_subprojects) > 0 and subproject not in target_subprojects:
print('skipping {}'.format(subproject))
continue
game_versions = read_prop('versions/{}/gradle.properties'.format(subproject), 'game_versions')
game_versions = read_prop(f'versions/{subproject}/gradle.properties', 'game_versions')
game_versions = game_versions.strip().replace('\r', '').replace('\n', ', ')
file_paths = glob.glob('build-artifacts/{}/build/libs/*.jar'.format(subproject))
file_paths = list(filter(lambda fp: not fp.endswith('-sources.jar') and not fp.endswith('-dev.jar') and not fp.endswith('-shadow.jar'), file_paths))
file_paths = glob.glob(f'build-artifacts/{subproject}/build/libs/*.jar')
file_paths = [fp for fp in sorted(file_paths) if all(not fp.endswith(f'-{classifier}.jar') for classifier in ['sources', 'dev', 'shadow'])]
if len(file_paths) == 0:
file_name = '*not found*'
sha256 = '*N/A*'
Expand All @@ -62,12 +71,39 @@ def main():
if len(file_paths) > 1:
warnings.append('Found too many build files in subproject {}: {}'.format(subproject, ', '.join(file_paths)))

f.write('| {} | {} | {} | {} | {} |\n'.format(subproject, game_versions, file_name, file_size, sha256))
f.write(f'| {subproject} | {game_versions} | {file_name} | {file_size} | {sha256} |\n')
f.write('\n')

f.write('## Artifact Files\n\n')
all_digests_are_sha256 = all(artifact['digest'].startswith('sha256:') for artifact in artifacts.values())
f.write('| Artifact | For | Size | {} | \n'.format('SHA-256' if all_digests_are_sha256 else 'Digest'))
f.write('| --- | --- | --- | --- |\n')
for artifact_name, artifact_usage in [
('mod-jars', 'Players who want to grab and install the mod jar into their Minecraft clients'),
('build-artifacts', 'Mod developers who want to inspect the complete build artifacts'),
]:
artifact_display_name = f'`{artifact_name}`'
artifact_size = 'unknown'
artifact_digest = 'unknown'
if artifact_name in artifacts:
# https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#list-workflow-run-artifacts
artifact: dict = artifacts[artifact_name]
try:
download_url = f'{os.environ["GITHUB_SERVER_URL"]}/{os.environ["GITHUB_REPOSITORY"]}/actions/runs/{os.environ["GITHUB_RUN_ID"]}/artifacts/{artifact["id"]}'
artifact_display_name = f'[`{artifact_name}`]({download_url})'
artifact_size = f'{artifact["size_in_bytes"]} B'
artifact_digest = '`{}`'.format(artifact["digest"].split(':', 1)[-1] if all_digests_are_sha256 else artifact["digest"])
except Exception as e:
warnings.append(f'Failed to collect artifact info for {artifact_name}: {e} -- {artifact}')

f.write(f'| {artifact_display_name} | {artifact_usage} | {artifact_size} | {artifact_digest} |\n')
f.write('\n')

if len(warnings) > 0:
f.write('\n### Warnings\n\n')
f.write('## Warnings\n\n')
for warning in warnings:
f.write('- {}\n'.format(warning))
f.write('\n')


if __name__ == '__main__':
Expand Down
38 changes: 19 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
id 'fabric-loom' version '1.14-SNAPSHOT' apply false
// https://github.com/ReplayMod/preprocessor
// https://github.com/Fallen-Breath/preprocessor
id 'com.replaymod.preprocess' version '9d21b334a7'
id 'com.replaymod.preprocess' version 'd452ef7612'
}

preprocess {
Expand All @@ -19,29 +19,29 @@ preprocess {
def mc1202 = createNode('1.20.2', 1_20_02, 'yarn')
def mc1204 = createNode('1.20.4', 1_20_04, 'yarn')
def mc1206 = createNode('1.20.6', 1_20_06, 'yarn')
def mc1210 = createNode('1.21.0', 1_21_00, 'yarn')
def mc1211 = createNode('1.21.1', 1_21_01, 'yarn')
def mc1213 = createNode('1.21.3', 1_21_03, 'yarn')
def mc1214 = createNode('1.21.4', 1_21_04, 'yarn')
def mc1215 = createNode('1.21.5', 1_21_05, 'yarn')
def mc12100 = createNode('1.21.0', 1_21_00, 'yarn')
def mc12101 = createNode('1.21.1', 1_21_01, 'yarn')
def mc12103 = createNode('1.21.3', 1_21_03, 'yarn')
def mc12104 = createNode('1.21.4', 1_21_04, 'yarn')
def mc12105 = createNode('1.21.5', 1_21_05, 'yarn')
def mc12108 = createNode('1.21.8', 1_21_08, 'yarn')
def mc12110 = createNode('1.21.10', 1_21_10, 'yarn')
def mc12111 = createNode('1.21.11', 1_21_11, 'yarn')

// mapping difference map
// mapping difference map (Why is it backwards?)
// base 1194 -> 1193 -> 1192 ->1190-> 118 -> 117 -> 116
mc1202.link(mc1201, file('versions/mapping-1.20.2-1.20.1.txt'))
mc1201.link(mc1194, file('versions/mapping-1.20.1-1.19.4.txt'))
mc1204.link(mc1202, file('versions/mapping-1.20.4-1.20.2.txt'))
mc1206.link(mc1204, file('versions/mapping-1.20.6-1.20.4.txt'))
mc1210.link(mc1206, file('versions/mapping-1.21.0-1.20.6.txt'))
mc1211.link(mc1210, file('versions/mapping-1.21.1-1.21.0.txt'))
mc1213.link(mc1211, file('versions/mapping-1.21.3-1.21.1.txt'))
mc1214.link(mc1213, file('versions/mapping-1.21.4-1.21.3.txt'))
mc1215.link(mc1214, file('versions/mapping-1.21.5-1.21.4.txt'))
//mc1194.link(mc1193, file('versions/mapping-1.19.4-1.19.3.txt'))
//mc1193.link(mc1192, file('versions/mapping-1.19.3-1.19.2.txt'))
//mc1192.link(mc1190, file('versions/mapping-1.19.2-1.19.0.txt'))
//mc1190.link(mc1182, file('versions/mapping-1.19.0-1.18.2.txt'))
//mc1182.link(mc1171, file('versions/mapping-1.18.2-1.17.1.txt'))
//mc1171.link(mc1165, file('versions/mapping-1.17.1-1.16.5.txt'))
mc1206.link(mc12100, null)
mc12100.link(mc12101, null)
mc12101.link(mc12103, null)
mc12103.link(mc12104, null)
mc12104.link(mc12105, null)
mc12105.link(mc12108, null)
mc12108.link(mc12110, null)
mc12110.link(mc12111, null)
}
// commands
// gradlew build -> build all subprojects
Expand Down
Loading
Loading