Skip to content

Commit

Permalink
Add draft-release.py script (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertteoh authored Jul 4, 2022
1 parent 5495068 commit dc936a6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
11 changes: 7 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
- If necessary, add a note detailing any impact to externally facing APIs.
1. Update `packages/jaeger-ui/package.json#version` to refer to the version being released.
1. Create a GitHub release.
- The tag and release must refer to the commit created when the PR from the previous step was merged.
- The tag name for the GitHub release should be the version for the release. It should include the "v", e.g. `v1.0.0`.
- The title of the release match the format "Jaeger UI vX.Y.Z".
- Copy the new CHANGELOG.md section into the release notes.
- Automated (requires [gh](https://cli.github.com/manual/installation)):
- `python ./scripts/draft-release.py`
- Manual:
- The tag and release must refer to the commit created when the PR from the previous step was merged.
- The tag name for the GitHub release should be the version for the release. It should include the "v", e.g. `v1.0.0`.
- The title of the release match the format "Jaeger UI vX.Y.Z".
- Copy the new CHANGELOG.md section into the release notes.
47 changes: 47 additions & 0 deletions scripts/draft-release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import re
import subprocess


release_header_pattern = re.compile(r"## (v[\d]+\.[\d]+\.[\d]) \([\d]{4}-[\d]{2}-[\d]{2}\)", flags=0)


def main():
changelog_text, version = get_changelog()
print(changelog_text)
output_string = subprocess.check_output(
["gh", "release", "create", version,
"--draft",
"--title", f"Jaeger UI {version}",
"--repo", "jaegertracing/jaeger-ui",
"-F", "-"],
input=changelog_text,
text=True,
)
print(f"Draft created at: {output_string}")
print("Please review, then edit it and click 'Publish release'.")


def get_changelog():
changelog_text = ""
in_changelog_text = False
version = ""
with open("CHANGELOG.md") as f:
for line in f:
m = release_header_pattern.match(line)

if m is not None:
# Found the first release.
if not in_changelog_text:
in_changelog_text = True
version = m.group(1)
else:
# Found the next release.
break
elif in_changelog_text:
changelog_text += line

return changelog_text, version


if __name__ == "__main__":
main()

0 comments on commit dc936a6

Please sign in to comment.