Skip to content

Commit

Permalink
fix summary script
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Feb 12, 2025
1 parent 777bc38 commit 5b814f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:

jobs:

matrix_prep:
uses: ./.github/workflows/matrix_prep.yml

build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -83,7 +80,6 @@ jobs:

- name: Make build summary
run: |
pip install jproperties
python .github/workflows/scripts/summary.py
env:
TARGET_VERSION: ${{ inputs.target_version }}
2 changes: 1 addition & 1 deletion .github/workflows/scripts/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main():
mc_ver = version['version']
platforms = version['platforms'].split('\n')
for platform in platforms:
subproject = f'{platform}-{mc_ver}'
subproject = f'{platform}-mc{mc_ver}'
jars.extend(glob.glob(f'versions/{subproject}/build/libs/*-relocate.jar'))

if len(jars) == 0:
Expand Down
30 changes: 7 additions & 23 deletions .github/workflows/scripts/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
import json
import os

import jproperties


def read_prop(file_name: str, key: str) -> str:
configs = jproperties.Properties()
with open(file_name, 'rb') as f:
configs.load(f)
return configs[key].data


def get_sha256_hash(file_path: str) -> str:
sha256_hash = hashlib.sha256()

Expand All @@ -31,38 +21,32 @@ def get_sha256_hash(file_path: str) -> str:


def main():
target_version_env = os.environ.get('TARGET_VERSION', '')
target_versions = list(filter(None, target_version_env.split(',') if target_version_env != '' else []))
print('target_versions: {}'.format(target_versions))

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('| --- | --- | --- | --- | --- |\n')
f.write('| for Minecraft | File | Size | SHA-256 |\n')
f.write('| --- | --- | --- | --- |\n')

warnings = []
for version in settings['versions']:
if len(target_versions) > 0 and version['version'] not in target_versions:
print('skipping {}'.format(version['version']))
continue
game_versions = version['game_versions']
game_versions = game_versions.strip().replace('\r', '').replace('\n', ', ')
file_paths = glob.glob('build-artifacts/build/libs/*.jar')
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/*-mc{version["version"]}-*.jar')
print(file_paths)
if len(file_paths) == 0:
file_name = '*not found*'
file_size = '*N/A*'
sha256 = '*N/A*'
else:
file_name = '`{}`'.format(os.path.basename(file_paths[0]))
file_size = '{} B'.format(os.path.getsize(file_paths[0]))
sha256 = '`{}`'.format(get_sha256_hash(file_paths[0]))
if len(file_paths) > 1:
warnings.append('Found too many build files in subproject {}: {}'.format(version, ', '.join(file_paths)))
warnings.append('Found too many build files in subproject {}: {}'.format(version['version'], ', '.join(file_paths)))

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

if len(warnings) > 0:
f.write('\n### Warnings\n\n')
Expand Down

0 comments on commit 5b814f4

Please sign in to comment.