Skip to content

Commit e2413ad

Browse files
committed
ci: update workflows & remove MCBBS mirror
1 parent 90de53a commit e2413ad

File tree

3 files changed

+118
-36
lines changed

3 files changed

+118
-36
lines changed

Diff for: .github/workflows/build.yml

+44-31
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,53 @@
1-
# Automatically build the project and run any configured tests for every push
2-
# and submitted pull request. This can help catch issues that only occur on
3-
# certain platforms or Java versions, and provides a first line of defence
4-
# against bad commits.
5-
61
name: build
72
on: [pull_request, push]
83

94
jobs:
105
build:
11-
strategy:
12-
matrix:
13-
# Use these Java versions
14-
java: [
15-
17, # Current Java LTS & minimum supported by Minecraft
16-
]
17-
# and run on both Linux and Windows
18-
os: [ubuntu-22.04, windows-2022]
19-
runs-on: ${{ matrix.os }}
6+
runs-on: ubuntu-latest
207
steps:
21-
- name: checkout repository
22-
uses: actions/checkout@v3
23-
- name: validate gradle wrapper
24-
uses: gradle/wrapper-validation-action@v1
25-
- name: setup jdk ${{ matrix.java }}
26-
uses: actions/setup-java@v3
8+
- uses: actions/checkout@v4
9+
10+
- name: Set up JDK ${{ matrix.java-version }}
11+
uses: actions/setup-java@v4
12+
with:
13+
distribution: 'temurin'
14+
java-version: 21
15+
16+
- name: Build with gradle
17+
run: |
18+
chmod +x gradlew
19+
echo "Building..."
20+
./gradlew build
21+
env:
22+
BUILD_ID: ${{ github.run_number }}
23+
BUILD_RELEASE: false
24+
25+
- name: Gather artifacts
26+
run: |
27+
mkdir gathered-artifacts
28+
cp -r versions/*/build/libs/* gathered-artifacts/
29+
30+
- name: Upload artifacts
31+
uses: actions/upload-artifact@v4
2732
with:
28-
java-version: ${{ matrix.java }}
29-
distribution: 'microsoft'
30-
- name: make gradle wrapper executable
31-
if: ${{ runner.os != 'Windows' }}
32-
run: chmod +x ./gradlew
33-
- name: build
34-
run: ./gradlew build
35-
- name: capture build artifacts
36-
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
37-
uses: actions/upload-artifact@v3
33+
name: Artifacts
34+
path: gathered-artifacts
35+
36+
summary:
37+
runs-on: ubuntu-22.04
38+
needs:
39+
- build
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Download all artifacts
45+
uses: actions/download-artifact@v4
3846
with:
3947
name: Artifacts
40-
path: build/libs/
48+
path: gathered-artifacts
49+
50+
- name: Make build summary
51+
run: python3 .github/workflows/scripts/summary.py # ubuntu-22.04 uses Python 3.10.6
52+
env:
53+
TARGET_SUBPROJECT: '' # leaving this empty means all subprojects

Diff for: .github/workflows/scripts/summary.py

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
A script to scan through all valid mod jars in the artifacts folder,
3+
and generate an artifact summary table for that to GitHub action step `summary`
4+
"""
5+
__author__ = 'Fallen_Breath(Original)' + '70CentsApple(Modified)'
6+
# Credits to https://github.com/Fallen-Breath/fabric-mod-template
7+
8+
import functools
9+
import glob
10+
import hashlib
11+
import json
12+
import os
13+
14+
15+
def read_prop(file_name: str, key: str) -> str:
16+
with open(file_name, 'r') as prop:
17+
return next(filter(
18+
lambda l: l.split('=', 1)[0].strip() == key,
19+
prop.readlines()
20+
)).split('=', 1)[1].lstrip()
21+
22+
23+
def get_sha256_hash(file_path: str) -> str:
24+
sha256_hash = hashlib.sha256()
25+
with open(file_path, 'rb') as f:
26+
for buf in iter(functools.partial(f.read, 4096), b''):
27+
sha256_hash.update(buf)
28+
return sha256_hash.hexdigest()
29+
30+
def main():
31+
MOD_VERSION = read_prop('gradle.properties', 'mod_version')
32+
print(f'Current mod version: {MOD_VERSION}')
33+
target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '')
34+
target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else []))
35+
print(f'target_subprojects: {target_subprojects}')
36+
37+
with open('settings.json') as f:
38+
settings: dict = json.load(f)
39+
40+
with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f:
41+
f.write('## 🍎 Build Artifacts Summary 🍎\n\n')
42+
f.write('| Subproject | File | Size | SHA-256 |\n')
43+
f.write('| --- | --- | --- | --- |\n')
44+
45+
warnings = []
46+
for subproject in settings['versions']:
47+
print(f'Found: {subproject}')
48+
if len(target_subprojects) > 0 and subproject not in target_subprojects:
49+
print(f'- Skipping {subproject}')
50+
continue
51+
# file_paths = glob.glob(f'/build/libs/{MOD_VERSION}/*{subproject}*.jar')
52+
file_paths = glob.glob(f'gathered-artifacts/*{subproject}*.jar')
53+
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))
54+
if len(file_paths) == 0:
55+
file_name = '*NOT FOUND*'
56+
file_size = '*N/A*'
57+
sha256 = '*N/A*'
58+
else:
59+
file_name = f'`{os.path.basename(file_paths[0])}`'
60+
file_size = f'{os.path.getsize(file_paths[0])} B'
61+
sha256 = f'`{get_sha256_hash(file_paths[0])}`'
62+
if len(file_paths) > 1:
63+
warnings.append(f'Found too many build files in subproject {subproject}: {", ".join(file_paths)}')
64+
65+
f.write(f'| {subproject} | {file_name} | {file_size} | {sha256} |\n')
66+
67+
if warnings:
68+
f.write('\n### Warnings\n\n')
69+
for warning in warnings:
70+
f.write(f'- {warning}\n')
71+
72+
73+
if __name__ == '__main__':
74+
main()

Diff for: gradle.properties

-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,3 @@
1212
maven_group=net.apple70cents
1313
archives_base_name=auto_twerk
1414

15-
# Global Dependencies
16-
17-
# Mirrors
18-
loom_resources_base = https://download.mcbbs.net/assets/
19-
loom_version_manifests = https://download.mcbbs.net/mc/game/version_manifest.json

0 commit comments

Comments
 (0)