|
14 | 14 |
|
15 | 15 | """Script to generate release notes."""
|
16 | 16 |
|
17 |
| -import os |
18 | 17 | import re
|
19 | 18 | import subprocess
|
20 | 19 | import sys
|
@@ -87,13 +86,13 @@ def get_relnotes_between(base, head, is_major_release):
|
87 | 86 |
|
88 | 87 | def get_label(issue_id):
|
89 | 88 | """Get team-X label added to issue."""
|
90 |
| - auth = os.system( |
| 89 | + auth = subprocess.check_output( |
91 | 90 | "gsutil cat"
|
92 | 91 | " gs://bazel-trusted-encrypted-secrets/github-trusted-token.enc |"
|
93 | 92 | " gcloud kms decrypt --project bazel-public --location global"
|
94 | 93 | " --keyring buildkite --key github-trusted-token --ciphertext-file"
|
95 |
| - " - --plaintext-file -" |
96 |
| - ) |
| 94 | + " - --plaintext-file -", shell=True |
| 95 | + ).decode("utf-8").strip().split("\n")[0] |
97 | 96 | headers = {
|
98 | 97 | "Authorization": "Bearer " + auth,
|
99 | 98 | "Accept": "application/vnd.github+json",
|
@@ -159,11 +158,16 @@ def get_external_authors_between(base, head):
|
159 | 158 | # e.g. if current_release is 5.3.3, last_release should be 5.3.2 even if
|
160 | 159 | # latest release is 6.1.1
|
161 | 160 | current_release = git("rev-parse", "--abbrev-ref", "HEAD")[0]
|
162 |
| - if not current_release.startswith("release-"): |
163 |
| - print("Error: Not a release- branch") |
164 |
| - sys.exit(1) |
165 | 161 |
|
166 |
| - current_release = re.sub(r"rc\d", "", current_release[len("release-"):]) |
| 162 | + if current_release.startswith("release-"): |
| 163 | + current_release = re.sub(r"rc\d", "", current_release[len("release-"):]) |
| 164 | + else: |
| 165 | + try: |
| 166 | + current_release = git("describe", "--tags")[0] |
| 167 | + except Exception: # pylint: disable=broad-exception-caught |
| 168 | + print("Error: Not a release branch.") |
| 169 | + sys.exit(1) |
| 170 | + |
167 | 171 | is_major = bool(re.fullmatch(r"\d+.0.0", current_release))
|
168 | 172 |
|
169 | 173 | tags = [tag for tag in git("tag", "--sort=refname") if "pre" not in tag]
|
|
0 commit comments