Skip to content

Commit

Permalink
Try to fix matrix.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Skidamek committed Jul 31, 2024
1 parent 91b30c4 commit 49caac6
Showing 1 changed file with 30 additions and 35 deletions.
65 changes: 30 additions & 35 deletions .github/workflows/scripts/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,36 @@


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

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

if len(target_subprojects) == 0:
subprojects = settings['versions']
else:
subprojects = []
for subproject in settings['versions']:
if subproject in target_subprojects:
subprojects.append(subproject)
target_subprojects.remove(subproject)
if len(target_subprojects) > 0:
print('Unexpected subprojects: {}'.format(target_subprojects), file=sys.stderr)
sys.exit(1)

matrix_entries = []
for subproject in subprojects:
mc_version = subproject.split('-')[0]
mod_brand = subproject.split('-')[1]
matrix_entries.append({
'subproject': subproject,
'mod_brand': mod_brand,
'mc_version': mc_version,
})
matrix = {'include': matrix_entries}
with open(os.environ['GITHUB_OUTPUT'], 'w') as f:
f.write('matrix={}\n'.format(json.dumps(matrix)))

print('matrix:')
print(json.dumps(matrix, indent=2))
target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '')
target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else []))
print('target_subprojects: {}'.format(target_subprojects))

subprojects = []
versions = os.listdir('./../../../versions')
for subproject in versions:
if subproject in target_subprojects:
subprojects.append(subproject)
target_subprojects.remove(subproject)
if len(target_subprojects) > 0:
print('Unexpected subprojects: {}'.format(target_subprojects), file=sys.stderr)
sys.exit(1)

matrix_entries = []
for subproject in subprojects:
mc_version = subproject.split('-')[0]
mod_brand = subproject.split('-')[1]
matrix_entries.append({
'subproject': subproject,
'mod_brand': mod_brand,
'mc_version': mc_version,
})
matrix = {'include': matrix_entries}
with open(os.environ['GITHUB_OUTPUT'], 'w') as f:
f.write('matrix={}\n'.format(json.dumps(matrix)))

print('matrix:')
print(json.dumps(matrix, indent=2))


if __name__ == '__main__':
main()
main()

0 comments on commit 49caac6

Please sign in to comment.