diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-05-04 14:53:01 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-05-04 14:57:17 +0300 |
commit | 8a8074e4322f939546b242eb363540c781fdc697 (patch) | |
tree | abb841763a653aeb81268fad9100a7bc1f7513b3 /_support | |
parent | 25f903dc882d233423ab9b5ee759860b920fc927 (diff) |
Put version in changelog during release
Diffstat (limited to '_support')
-rwxr-xr-x | _support/release | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/_support/release b/_support/release index 96e009c6e..091004639 100755 --- a/_support/release +++ b/_support/release @@ -13,11 +13,11 @@ def main(version) puts 'Testing for staged changes' run!(%w[git diff --quiet --cached --exit-code]) + tag_name = "v#{version}" write_version_file(version) + update_changelog(tag_name) version_msg = "Version #{version}" run!(%W[git commit -m #{version_msg}]) - - tag_name = "v#{version}" run!(%W[git tag -a -m #{version_msg} #{tag_name}]) # We use 'capture!' to prevent 'git show' from invoking 'less'. @@ -42,6 +42,19 @@ def write_version_file(version) run!(%W[git add #{version_file}]) end +def update_changelog(version_string) + changelog = 'CHANGELOG.md' + content = IO.read(changelog).lines + unreleased_line = "UNRELEASED\n" + version_index = content.find_index { |l| l == unreleased_line } + if version_index.nil? + abort "no #{unreleased_line.inspect} line found in #{changelog}" + end + content[version_index] = version_string + "\n" + IO.write(changelog, content.join) + run!(%W[git add #{changelog}]) +end + def error(msg) warn "#{$0}: #{msg}" end |