From c3b41a53751bc5a30b695f9c38ee9635a0d5104c Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Sun, 21 Jan 2024 15:38:47 +0100 Subject: [PATCH] Support `release/` branches --- .github/deploy.py | 21 +++++++++++++-------- .github/workflows/windows-all.yml | 1 + .github/workflows/windows-quick.yml | 1 + api/python/backend/versioning.py | 4 ++++ cmake/LIEFGit.cmake | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/deploy.py b/.github/deploy.py index d1461463fc..c872af8dcc 100644 --- a/.github/deploy.py +++ b/.github/deploy.py @@ -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() @@ -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 @@ -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) diff --git a/.github/workflows/windows-all.yml b/.github/workflows/windows-all.yml index 7495c3fc10..524af7c341 100644 --- a/.github/workflows/windows-all.yml +++ b/.github/workflows/windows-all.yml @@ -4,6 +4,7 @@ on: branches: - 'master' - 'release-**' + - 'release/**' tags: - '**' diff --git a/.github/workflows/windows-quick.yml b/.github/workflows/windows-quick.yml index 5b0b78e1b1..a38a1b8471 100644 --- a/.github/workflows/windows-quick.yml +++ b/.github/workflows/windows-quick.yml @@ -5,6 +5,7 @@ on: - '**' - '!master' - '!release-**' + - '!release/**' tags-ignore: - "**" diff --git a/api/python/backend/versioning.py b/api/python/backend/versioning.py index efcf87d168..041bacc271 100644 --- a/api/python/backend/versioning.py +++ b/api/python/backend/versioning.py @@ -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 diff --git a/cmake/LIEFGit.cmake b/cmake/LIEFGit.cmake index 5462886103..dfc6adc3db 100644 --- a/cmake/LIEFGit.cmake +++ b/cmake/LIEFGit.cmake @@ -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() @@ -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")