Skip to content

Commit

Permalink
Fix github actions tag parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Jan 27, 2024
1 parent 326f491 commit 8673d05
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,16 @@ def seven_zip_compress(input_path, output_path):
def get_chapter_name_and_translation_from_git_tag():
returned_chapter_name = None
translation = False
tag_fragments_debug = 'tag fragments not extracted - maybe missing GITHUB_REF?' #type: str

if GIT_TAG is None:
raise Exception(
"'github_actions' was selected, but environment variable GITHUB_REF was not set - are you sure you're running this script from Github Actions?"
)
else:
# Look for the chapter name to build in the git tag
tag_fragments = [x.lower() for x in re.split(r"[\W_]", GIT_REF)]
tag_fragments = [x.lower() for x in re.split(r"_", GIT_REF)]
tag_fragments_debug = str(tag_fragments)

if "all" in tag_fragments:
returned_chapter_name = "all"
Expand All @@ -218,7 +220,7 @@ def get_chapter_name_and_translation_from_git_tag():
if "translation" in tag_fragments:
translation = True

return returned_chapter_name, translation
return returned_chapter_name, translation, tag_fragments_debug


def get_build_variants(selected_chapter: str) -> List[BuildVariant]:
Expand Down Expand Up @@ -323,11 +325,12 @@ def save(self):
# Get chapter name from git tag if "github_actions" specified as the chapter
chapter_name = args.chapter
if chapter_name == "github_actions":
chapter_name, translation = get_chapter_name_and_translation_from_git_tag()
chapter_name, translation, tag_fragments_debug = get_chapter_name_and_translation_from_git_tag()
if chapter_name is None:
print(
f">>>> WARNING: No chapter name (or 'all') was found in git tag {GIT_TAG} - skipping building .assets"
f">>>> WARNING: No chapter name was found in git tag {GIT_TAG} parsed as {tag_fragments_debug} - skipping building .assets"
)
print(f">>>> Should contain one of {chapter_to_build_variants.keys()} or 'all'")
exit(0)

# NOTE: For now, translation archive output is enabled by default, as most of the time this script will be used for translators
Expand Down

0 comments on commit 8673d05

Please sign in to comment.