Skip to content

Commit f6d4e2e

Browse files
committed
Output translation archive from CI, see #12
1 parent a0e717d commit f6d4e2e

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

build.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,36 @@ def seven_zip_extract(input_path, outputDir=None):
153153

154154
call(args)
155155

156+
def seven_zip_compress(input_path, output_path):
157+
args = ["7z", "a", "-md=512m", output_path, input_path, "-y"]
158+
159+
call(args)
160+
161+
162+
def get_chapter_name_and_translation_from_git_tag():
163+
returned_chapter_name = None
164+
translation = False
156165

157-
def get_chapter_name_from_git_tag():
158166
if GIT_TAG is None:
159167
raise Exception(
160-
"'github_actions' was selected, but environment variable GIT_REF was not set - are you sure you're running this script from Github Actions?"
168+
"'github_actions' was selected, but environment variable GITHUB_REF was not set - are you sure you're running this script from Github Actions?"
161169
)
162170
else:
163171
# Look for the chapter name to build in the git tag
164172
tag_fragments = [x.lower() for x in re.split("[\W_]", GIT_REF)]
165173

166174
if "all" in tag_fragments:
167-
return "all"
175+
returned_chapter_name = "all"
168176
else:
169177
for chapter_name in chapter_to_build_variants.keys():
170178
if chapter_name.lower() in tag_fragments:
171-
return chapter_name
179+
returned_chapter_name = chapter_name
180+
break
181+
182+
if "translation" in tag_fragments:
183+
translation = True
172184

173-
return None
185+
return returned_chapter_name, translation
174186

175187

176188
def get_build_variants(selected_chapter: str) -> List[BuildVariant]:
@@ -244,18 +256,23 @@ def save(self):
244256
args = parser.parse_args()
245257

246258
force_download = args.force_download
259+
260+
# NOTE: For now, translation archive output is always enabled, as most of the time this script will be used for translators
247261
translation = args.translation
248262

249263
# Get chapter name from git tag if "github_actions" specified as the chapter
250264
chapter_name = args.chapter
251265
if chapter_name == "github_actions":
252-
chapter_name = get_chapter_name_from_git_tag()
266+
chapter_name, translation = get_chapter_name_and_translation_from_git_tag()
253267
if chapter_name is None:
254268
print(
255269
f">>>> WARNING: No chapter name (or 'all') was found in git tag {GIT_TAG} - skipping building .assets"
256270
)
257271
exit(0)
258272

273+
# NOTE: For now, translation archive output is always enabled, as most of the time this script will be used for translators
274+
translation = True
275+
259276
# Get a list of build variants (like 'onikakushi 5.2.2f1 win') depending on commmand line arguments
260277
build_variants = get_build_variants(chapter_name)
261278
build_variants_list = "\n - ".join([b.get_build_command() for b in build_variants])
@@ -347,3 +364,11 @@ def save(self):
347364
if build_variant.translation_default:
348365
destination_default_sharedassets = os.path.join(translation_data_dir, "sharedassets0.assets")
349366
shutil.copyfile(source_sharedassets, destination_default_sharedassets)
367+
368+
if translation:
369+
containing_folder = "output"
370+
output_path = "output/translation.7z"
371+
if os.path.exists(output_path):
372+
os.remove(output_path)
373+
374+
seven_zip_compress('output/translation', output_path)

0 commit comments

Comments
 (0)