-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Update changelog more consistently #3405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ | |
import os | ||
import textwrap | ||
|
||
from dateutil.parser import parse | ||
from future.moves.configparser import RawConfigParser | ||
from invoke import task | ||
from invoke import task, Exit | ||
|
||
|
||
@task | ||
|
@@ -24,6 +25,13 @@ def prepare(ctx, version): | |
updated. New entries will end up at the top of the file, under a heading | ||
for the new version. | ||
""" | ||
# Ensure we're on the master branch first | ||
git_rev_parse = ctx.run('git rev-parse --abbrev-ref HEAD', hide=True) | ||
current_branch = git_rev_parse.stdout.strip() | ||
if current_branch != 'rel': | ||
print('You must be on master branch!') | ||
raise Exit(1) | ||
|
||
print('Updating release version in setup.cfg') | ||
setupcfg_path = os.path.join(os.path.dirname(__file__), 'setup.cfg') | ||
config = RawConfigParser() | ||
|
@@ -33,6 +41,11 @@ def prepare(ctx, version): | |
config.write(configfile) | ||
|
||
print('Installing github-changelog') | ||
# Get last modified date from Git instead of assuming the file metadata is | ||
# correct. This can change depending on git reset, etc. | ||
git_log = ctx.run('git log -1 --format="%ad" -- CHANGELOG.rst') | ||
last_modified = parse(git_log.stdout.strip()).strftime('%Y-%m-%d') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should put a note in the changelog that it's auto-generated, and not to touch it manually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, one of the benefits of this tool is that it only updates the changelog for last release. It does allow for authoring in between generating and commiting, so we can add deployment and migration notes, or more general description of some of the changes |
||
# Install and run | ||
ctx.run('npm install git+https://github.com/agjohnson/github-changelog.git') | ||
changelog_path = os.path.join(os.path.dirname(__file__), 'CHANGELOG.rst') | ||
template_path = os.path.join( | ||
|
@@ -44,12 +57,14 @@ def prepare(ctx, version): | |
'gh-changelog ' | ||
'-o rtfd -r readthedocs.org ' | ||
'--file {changelog_path} ' | ||
'--since {last_modified} ' | ||
'--template {template_path} ' | ||
'--header "Version {version}"' | ||
).format( | ||
version=version, | ||
template_path=template_path, | ||
changelog_path=changelog_path, | ||
last_modified=last_modified, | ||
) # yapf: disable | ||
try: | ||
token = os.environ['GITHUB_TOKEN'] | ||
|
@@ -76,6 +91,5 @@ def release(ctx, version): | |
Do this after prepare task and manual cleanup/commit | ||
""" | ||
ctx.run( | ||
('git checkout master && ' | ||
'git tag {version} && ' | ||
('git tag {version} && ' | ||
'git push --tags').format(version=version)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
rel
here? shouldn't bemaster
?I mean, it checks if we are in
rel
and if not, it says "hey, you need to be on master"Other, we want to ensure we are on
rel
not onmaster
, right?