Skip to content

Commit

Permalink
fix(license): remove benchmark license when build (apache#1562)
Browse files Browse the repository at this point in the history
## What does this PR do?
Benchmark code are excluded from source release, we should remove
license mention in the final LICENSE file.

The NOTICE fof those files are empty, so no need to change NOTICE file


## Related issues

apache#1389 


## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/incubator-fury/issues/new/choose)
describing the need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?


## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
  • Loading branch information
chaokunyang authored Apr 24, 2024
1 parent ca2f873 commit 7ada229
Showing 1 changed file with 68 additions and 5 deletions.
73 changes: 68 additions & 5 deletions ci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,46 @@
PROJECT_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")


def prepare(v: str):
"""Create a new release branch"""
logger.info("Start to prepare release branch for version %s", v)
_check_release_version(v)
os.chdir(PROJECT_ROOT_DIR)
branch = f"releases-{v}"
try:
subprocess.check_call(f"git checkout -b {branch}", shell=True)
bump_version(version=v, l="all")
subprocess.check_call("git add -u", shell=True)
subprocess.check_call(f"git commit -m 'prepare release for {v}'", shell=True)
except BaseException:
logger.exception("Prepare branch failed")
subprocess.check_call(f"git checkout - && git branch -D {branch}", shell=True)
raise


def build(v: str):
"""version format: 0.5.0"""
assert v
logger.info("Start to prepare release artifacts for version %s", v)
if "rc" in v:
raise ValueError(
"RC should only be contained in tag and svn directory, not in code"
)
_check_release_version(v)
os.chdir(PROJECT_ROOT_DIR)
if os.path.exists("dist"):
shutil.rmtree("dist")
os.mkdir("dist")
subprocess.check_call(f"git checkout releases-{v}", shell=True)
branch = f"releases-{v}"
src_tar = f"apache-fury-{v}-incubating-src.tar.gz"
_check_all_committed()
_strip_unnecessary_license()
subprocess.check_call(
"git add LICENSE && git commit -m 'remove benchmark from license'", shell=True
)
subprocess.check_call(
f"git archive --format=tar.gz "
f"--output=dist/{src_tar} "
f"--prefix=apache-fury-{v}-incubating-src/ {branch}",
shell=True,
)
subprocess.check_call("git reset --hard HEAD~", shell=True)
os.chdir("dist")
logger.info("Start to generate signature")
subprocess.check_call(
Expand All @@ -59,6 +78,43 @@ def build(v: str):
verify(v)


def _check_release_version(v: str):
assert v
if "rc" in v:
raise ValueError(
"RC should only be contained in tag and svn directory, not in code"
)


def _check_all_committed():
proc = subprocess.run("git diff --quiet", capture_output=True, shell=True)
result = proc.returncode
if result != 0:
raise Exception(
f"There are some uncommitted files: {proc.stdout}, please commit it."
)


def _strip_unnecessary_license():
with open("LICENSE", "r") as f:
lines = f.readlines()
new_lines = []
line_number = 0
while line_number < len(lines):
line = lines[line_number]
if "fast-serialization" in line:
line_number += 4
elif "benchmark" in line: # strip license in benchmark
line_number += 1
else:
new_lines.append(line)
line_number += 1
text = "".join(new_lines)
if lines != new_lines:
with open("LICENSE", "w") as f:
f.write(text)


def verify(v):
src_tar = f"apache-fury-{v}-incubating-src.tar.gz"
subprocess.check_call(f"gpg --verify {src_tar}.asc {src_tar}", shell=True)
Expand Down Expand Up @@ -200,6 +256,13 @@ def _parse_args():
bump_version_parser.add_argument("-l", type=str, help="language")
bump_version_parser.set_defaults(func=bump_version)

prepare_parser = subparsers.add_parser(
"prepare",
description="Prepare release branch",
)
prepare_parser.add_argument("-v", type=str, help="new version")
prepare_parser.set_defaults(func=prepare)

release_parser = subparsers.add_parser(
"build",
description="Build release artifacts",
Expand Down

0 comments on commit 7ada229

Please sign in to comment.