scripts: add changelog to release draft (#4791)
* scripts: add changelog to release draft * scripts: fix run command * rename variable * rename variable * fix command * add comment * rename variable Co-authored-by: Stefan Benten <mail@stefan-benten.de>
This commit is contained in:
parent
77357f9877
commit
352e937813
65
scripts/changelog.py
Normal file
65
scripts/changelog.py
Normal file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
# Example of usage: changelog.py <old-release-tag> <new-release-tag>
|
||||
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
GENERAL = "General"
|
||||
SATELLITE = "Satellite"
|
||||
STORAGENODE = "Storagenode"
|
||||
TEST = "Test"
|
||||
UPLINK = "Uplink"
|
||||
GITHUB_LINK = "[{0}](https://github.com/storj/storj/commit/{0})"
|
||||
|
||||
|
||||
def git_ref_field(from_ref, to_ref):
|
||||
# Execute command to show diff without cherry-picks
|
||||
cmd = "git cherry {} {} -v | grep '^+'".format(from_ref, to_ref)
|
||||
ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
output = ps.communicate()[0]
|
||||
return output.decode()
|
||||
|
||||
|
||||
def generate_changelog(commits):
|
||||
changelog = "# Changelog\n"
|
||||
section = {SATELLITE: [], STORAGENODE: [], TEST: [], UPLINK: [], GENERAL: []}
|
||||
|
||||
# Sorting and populating the dictionary d with commit hash and message
|
||||
for commit in commits.splitlines():
|
||||
if TEST.lower() in commit[42:].split(":")[0]:
|
||||
section[TEST].append(generate_line(commit))
|
||||
elif STORAGENODE.lower() in commit[42:].split(":")[0]:
|
||||
section[STORAGENODE].append(generate_line(commit))
|
||||
elif UPLINK.lower() in commit[42:].split(":")[0]:
|
||||
section[UPLINK].append(generate_line(commit))
|
||||
elif SATELLITE.lower() in commit[42:].split(":")[0]:
|
||||
section[SATELLITE].append(generate_line(commit))
|
||||
else:
|
||||
section[GENERAL].append(generate_line(commit))
|
||||
|
||||
for title in dict(sorted(section.items())):
|
||||
if section[title]:
|
||||
changelog += ('### {}\n'.format(title))
|
||||
for line in section[title]:
|
||||
changelog += line
|
||||
return changelog
|
||||
|
||||
|
||||
def generate_line(commit):
|
||||
return "- {}{} \n".format(GITHUB_LINK.format(commit[2:9]), commit[42:])
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=(
|
||||
"generate changelog sorted by topics."))
|
||||
p.add_argument("from_ref", help="the ref to show the path from")
|
||||
p.add_argument("to_ref", help="the ref to show the path to")
|
||||
args = p.parse_args()
|
||||
commits = git_ref_field(args.from_ref, args.to_ref)
|
||||
|
||||
print(generate_changelog(commits))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -15,16 +15,17 @@ fi
|
||||
FOLDER="${2-}"
|
||||
|
||||
echo "Drafting release"
|
||||
github-release release --user storj --repo storj --tag "$TAG" --draft
|
||||
current_release_version=$(echo "$TAG" | cut -d '.' -f 1-2)
|
||||
previous_release_version=$(git describe --tags $(git rev-list --exclude='*rc*' --exclude=$current_release_version* --tags --max-count=1))
|
||||
changelog=$(python3 changelog.py "$previous_release_version" "$TAG" 2>&1)
|
||||
github-release release --user storj --repo storj --tag "$TAG" --description "$changelog" --draft
|
||||
|
||||
echo "Sleep 10 seconds in order to wait for release propagation"
|
||||
sleep 10
|
||||
|
||||
echo "Uploading binaries to release draft"
|
||||
for app in $apps;
|
||||
do
|
||||
for file in "$FOLDER/$app"*.zip
|
||||
do
|
||||
for app in $apps; do
|
||||
for file in "$FOLDER/$app"*.zip; do
|
||||
github-release upload --user storj --repo storj --tag "$TAG" --name $(basename "$file") --file "$file"
|
||||
done
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user