aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2018-01-29 05:26:31 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-29 05:28:33 -0800
commitf7f37be17506d41c7436807791611c31e216c45c (patch)
tree274ffc175bc335d95721f8203f8db6cd84f67519 /scripts
parent8130287c0a921816ada6aa95eb968c1d8e6c1b0f (diff)
Simplify generate-changelog-file rule
The debian package changlog file doesn't have to contain the real CHANGELOG.md. Parsing change log is error-prone and caused our release job to fail everytime, so here we simplified the script for generating changelog. Fix https://github.com/bazelbuild/bazel/issues/4530 Change-Id: I8adc5a98def5709ea57f9edbed9f0cf772a48d76 PiperOrigin-RevId: 183651058
Diffstat (limited to 'scripts')
-rw-r--r--scripts/packages/debian/BUILD5
-rw-r--r--scripts/packages/debian/convert_changelog.py89
-rw-r--r--scripts/packages/debian/generate_changelog.py42
3 files changed, 44 insertions, 92 deletions
diff --git a/scripts/packages/debian/BUILD b/scripts/packages/debian/BUILD
index 3180079241..f82f37789b 100644
--- a/scripts/packages/debian/BUILD
+++ b/scripts/packages/debian/BUILD
@@ -98,12 +98,11 @@ filegroup(
genrule(
name = "generate-changelog-file",
srcs = [
- "convert_changelog.py",
- "//:changelog-file",
+ "generate_changelog.py",
"//:bazel-srcs", # Force a rebuild on source change
],
outs = ["changelog"],
- cmd = "python $(location convert_changelog.py) bazel-out/volatile-status.txt $(location //:changelog-file) $(location changelog)",
+ cmd = "python $(location generate_changelog.py) bazel-out/volatile-status.txt $(location changelog)",
stamp = 1,
)
diff --git a/scripts/packages/debian/convert_changelog.py b/scripts/packages/debian/convert_changelog.py
deleted file mode 100644
index a124807c4f..0000000000
--- a/scripts/packages/debian/convert_changelog.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# pylint: disable=g-bad-file-header
-# Copyright 2015 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""This tool convert Bazel's changelog file to debian changelog format."""
-
-from datetime import datetime
-import sys
-
-
-def main(input_file, changelog_file, output_file):
- changelog_out = open(output_file, "w")
- changelog = None
- version = None
- with open(input_file, "r") as status_file:
- for line in status_file:
- line = line.strip()
-
- if line.startswith("RELEASE_NOTES"):
- changelog = line[14:].strip().replace("\f", "\n")
- elif line.startswith("RELEASE_NAME"):
- version = line[13:].strip()
-
- if changelog:
- time_stamp = None
- lines = changelog.split("\n")
- header = lines[0]
- lines = lines[4:] # Skip the header
- if lines[0] == "Cherry picks:":
- # Skip cherry picks list
- i = 1
- while i < len(lines) and lines[i].strip():
- i += 1
- lines = lines[i + 1:]
-
- # Process header
- parts = header.split(" ")
- time_stamp = datetime.strptime(
- parts[2], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100")
- changelog_out.write("bazel (%s) unstable; urgency=low\n" % version)
-
- for line in lines:
- if line.startswith("+") or line.startswith("-"):
- parts = line.split(" ")
- line = "*" + line[1:]
- changelog_out.write(" %s\n" % line)
-
- elif line.endswith(":"):
- changelog_out.write("\n %s\n" % line)
-
- elif line:
- changelog_out.write(" %s\n" % line)
-
- if time_stamp:
- changelog_out.write(
- "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
- time_stamp)
- else:
- # Develeopment version, generate a changelog from the change log file
- with open(changelog_file, "r") as changelog_in:
- for line in changelog_in:
- line = line.strip()
- if line.startswith("## Release"):
- parts = line.split(" ")
- version = parts[2]
- time_stamp = datetime.strptime(
- parts[3], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100")
- changelog_out.write("bazel (%s~HEAD) unstable; urgency=low\n" %
- version)
- changelog_out.write(" Development version\n")
- changelog_out.write(
- "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
- time_stamp)
- # Stop after parsing latest release
- return
-
-
-if __name__ == "__main__":
- main(sys.argv[1], sys.argv[2], sys.argv[3])
diff --git a/scripts/packages/debian/generate_changelog.py b/scripts/packages/debian/generate_changelog.py
new file mode 100644
index 0000000000..df4d903429
--- /dev/null
+++ b/scripts/packages/debian/generate_changelog.py
@@ -0,0 +1,42 @@
+# pylint: disable=g-bad-file-header
+# Copyright 2015 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""This tool generates a debian changelog file."""
+
+from datetime import datetime
+import sys
+
+
+def main(input_file, output_file):
+ changelog_out = open(output_file, "w")
+ version = None
+ with open(input_file, "r") as status_file:
+ for line in status_file:
+ line = line.strip()
+ if line.startswith("RELEASE_NAME "):
+ version = line[len("RELEASE_NAME "):].strip()
+
+ if version:
+ changelog_out.write("bazel (%s) unstable; urgency=low\n" % version)
+ changelog_out.write("\n Bumped Bazel version to %s.\n" % version)
+ else:
+ changelog_out.write("bazel (@HEAD) unstable; urgency=low\n")
+ changelog_out.write("\n Development version\n")
+ changelog_out.write(
+ "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
+ datetime.now().strftime("%a, %d %b %Y %H:%M:%S +0100"))
+
+
+if __name__ == "__main__":
+ main(sys.argv[1], sys.argv[2])