Skip to content

Make the release script update Gemfile.lock #1711

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

Merged
merged 3 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ If you think ShakaCode can help your project, [click here](https://meetings.hubs

## Contributors

Please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide, and add a link for the version diff at the bottom of the file. Also, please update the `Unreleased` link to compare to the latest release version.
Please follow the recommendations outlined at [keepachangelog.com](http://keepachangelog.com/). Please use the existing headings and styling as a guide.
After a release, please make sure to run `bundle exec rake update_changelog`. This will add a heading for the latest version and update the links at the end of the file.

## Versions

### [15.0.0-alpha.2] - 2025-03-07
### [Unreleased]

Changes since the last non-beta release.

### [15.0.0-alpha.2] - 2025-03-07

See [Release Notes](docs/release-notes/15.0.0.md) for full details.

#### Added
Expand Down Expand Up @@ -1531,7 +1534,8 @@ such as:

- Fix several generator-related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.2.0...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/15.0.0-alpha.2...master
[15.0.0-alpha.2]: https://github.com/shakacode/react_on_rails/compare/14.2.0...15.0.0-alpha.2
[14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0
[14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
[14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0
Expand Down
8 changes: 5 additions & 3 deletions rakelib/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
sh_in_dir(gem_root, "gem release") unless is_dry_run

msg = <<~MSG
Once you have successfully published, run these commands to update the spec apps:
Once you have successfully published, run these commands to update Gemfile.lock and CHANGELOG.md:

bundle install
bundle exec rake update_changelog
cd #{dummy_app_dir}; bundle update react_on_rails
cd #{gem_root}#{' '}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could keep it but I don't see why the space would be useful.

git commit -a -m 'Update Gemfile.lock for spec app'
cd #{gem_root}
git commit -a -m 'Update Gemfile.lock and CHANGELOG.md'
git push
MSG
puts msg
Expand Down
2 changes: 1 addition & 1 deletion rakelib/task_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def bundle_install_in_no_turbolinks(dir)

# Runs bundle exec using that directory's Gemfile
def bundle_exec(dir: nil, args: nil, env_vars: "")
sh_in_dir(dir, "#{env_vars} #{args}")
sh_in_dir(dir, "#{env_vars} bundle exec #{args}")
end

def generators_source_dir
Expand Down
44 changes: 44 additions & 0 deletions rakelib/update_changelog.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require "English"
require "bundler"
require_relative "task_helpers"

desc "Updates CHANGELOG.md inserting headers for the new version.

Argument: Git tag. Defaults to the latest tag."

task :update_changelog, %i[tag] do |_, args|
tag = args[:tag] || `git describe --tags --abbrev=0`.strip
Copy link
Collaborator Author

@alexeyr-ci alexeyr-ci Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sh_in_dir is less convenient because it returns an array.

anchor = "[#{tag}]"

changelog = File.read("CHANGELOG.md")

if changelog.include?(anchor)
puts "Tag #{tag} is already documented in CHANGELOG.md, update manually if needed"
next
end

tag_date_output = `git show -s --format=%cs #{tag} 2>&1`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $CHILD_STATUS.success?
tag_date = tag_date_output.split("\n").last.strip
else
abort("Failed to find tag #{tag}")
end

# after "Changes since the last non-beta release.", insert link header
changelog.sub!("Changes since the last non-beta release.", "\\0\n\n### #{anchor} - #{tag_date}")

# find the link in "[Unreleased]: ...", update it, and add the link for our new tag after it
compare_link_prefix = "https://github.com/shakacode/react_on_rails/compare"
match_data = %r{#{compare_link_prefix}/(?<prev_tag>.*)\.\.\.master}.match(changelog)
if match_data
prev_tag = match_data[:prev_tag]
new_unreleased_link = "#{compare_link_prefix}/#{tag}...master"
new_tag_link = "#{anchor}: #{compare_link_prefix}/#{prev_tag}...#{tag}"
changelog.sub!(match_data[0], "#{new_unreleased_link}\n#{new_tag_link}")
end

File.write("CHANGELOG.md", changelog)
puts "Updated CHANGELOG.md with an entry for #{tag}"
end
Loading