Skip to content

Commit

Permalink
Support release/ branches
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Jan 21, 2024
1 parent 9c4c72f commit c3b41a5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
21 changes: 13 additions & 8 deletions .github/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
LIEF_S3_KEY = os.getenv("LIEF_S3_KEY", None)
LIEF_S3_SECRET = os.getenv("LIEF_S3_SECRET", None)
OWNED_ORGS = ["lief-project/", "romainthomas/"]
RELEASE_KEYWORD = "release-"
RELEASE_KEYWORD = ["release-", "release/"]

DEFAULT_CONFIG = CONFIG_DIR / "gh-ci.toml"
DEFAULT_TEMPLATE = (ASSET_DIR / "index.j2").read_text()
Expand Down Expand Up @@ -256,9 +256,11 @@ def should_be_deployed(self, branch: str) -> bool:
if any(re.match(s, branch) for s in self._branches):
return True

if branch.startswith(RELEASE_KEYWORD):
if any(branch.startswith(e) for e in RELEASE_KEYWORD):
return True

return False

def deploy(self, directories: list[str]):
s3dir = None
tag = None
Expand All @@ -272,12 +274,15 @@ def deploy(self, directories: list[str]):
logger.warning("Can't resolve the branch name")
sys.exit(1)

if branch.startswith(RELEASE_KEYWORD):
_, s3dir = branch.split(RELEASE_KEYWORD)
elif self.is_main_branch(branch):
s3dir = self._default_dir
else:
s3dir = branch.replace("/", "-").replace("_", "-")
for rel_kwrd in RELEASE_KEYWORD:
if branch.startswith(rel_kwrd):
_, s3dir = branch.split(rel_kwrd)
if s3dir is None:

if self.is_main_branch(branch):
s3dir = self._default_dir
else:
s3dir = branch.replace("/", "-").replace("_", "-")

if not self.should_be_deployed(branch):
logger.info("Skipping deployment for branch: %s", branch)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- 'master'
- 'release-**'
- 'release/**'
tags:
- '**'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- '**'
- '!master'
- '!release-**'
- '!release/**'
tags-ignore:
- "**"

Expand Down
4 changes: 4 additions & 0 deletions api/python/backend/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def format_version(self, version: str, fmt: str, is_dev: bool = False):
_, version = branch.split("release-")
return version

if branch is not None and branch.startswith("release/"):
_, version = branch.split("release/")
return version

parts = version.split('-')
assert len(parts) in (3, 4)
dirty = len(parts) == 4
Expand Down
4 changes: 2 additions & 2 deletions cmake/LIEFGit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message(STATUS "Tagged: ${LIEF_IS_TAGGED}")
if (${LIEF_IS_TAGGED})
message(STATUS "Tag: ${LIEF_GIT_TAG}")
else()
if(LIEF_GIT_BRANCH MATCHES "^release-")
if(LIEF_GIT_BRANCH MATCHES "^release[-/]")
string(REGEX MATCHALL "([0-9]+)" VERSION_STRING "${LIEF_GIT_BRANCH}")
message(STATUS "${VERSION_STRING}")
endif()
Expand All @@ -61,7 +61,7 @@ if (VERSION_STRING)
list(GET VERSION_STRING 2 LIEF_VERSION_PATCH)

if (NOT ${LIEF_IS_TAGGED})
if(LIEF_GIT_BRANCH MATCHES "^release-")
if(LIEF_GIT_BRANCH MATCHES "^release[-/]")
message(STATUS "Release branch")
else()
MATH(EXPR LIEF_VERSION_MINOR "${LIEF_VERSION_MINOR}+1")
Expand Down

0 comments on commit c3b41a5

Please sign in to comment.