|
3 | 3 |
|
4 | 4 | require 'tempfile' |
5 | 5 | require_relative 'scripty' |
| 6 | +include Scripty # rubocop:disable Style/MixinUsage |
6 | 7 |
|
7 | 8 | # Abort if the working tree is dirty |
8 | 9 | abort('Working tree dirty!') unless `git status --porcelain`.empty? |
|
21 | 22 | new_fragments = new_version.split('.') |
22 | 23 | abort('Incomplete semantic version!') if new_fragments.size < 3 |
23 | 24 |
|
24 | | -# Abort if there is no gem change |
25 | | -abort("No gem changes since version #{old_version}!") \ |
26 | | - if `git diff --name-only --relative=gem "#{old_version}"..HEAD`.empty? |
27 | | - |
28 | | -# Bump the version in files |
29 | | -%w[retype.yml |
30 | | - .github/ISSUE_TEMPLATE/Code.yml |
31 | | - .github/latest_release_body.md |
32 | | - gem/apps/calendar.ru |
33 | | - gem/apps/demo.ru |
34 | | - gem/apps/rails.ru |
35 | | - gem/apps/repro.ru |
36 | | - gem/bin/pagy |
37 | | - gem/config/pagy.rb |
38 | | - gem/lib/pagy.rb |
39 | | - gem/pagy.gemspec |
40 | | - src/pagy.ts].each do |path| |
41 | | - Scripty.file_sub(path, old_version, new_version) |
42 | | -end |
43 | | - |
44 | | -# Bumps docs example |
45 | | -Scripty.file_sub('quick-start.md', |
46 | | - old_version.split('.')[0, 2].join('.'), |
47 | | - new_version.split('.')[0, 2].join('.')) |
48 | | - |
49 | | -# Build javascript files |
50 | | -system(Scripty::ROOT.join('src/build').to_s) |
51 | | - |
52 | 25 | # Create a tempfile with the formatted changes from the gem-filtered gitlog |
53 | 26 | gitlog = Tempfile.new |
54 | 27 | commits = `git rev-list "#{old_version}"..HEAD`.split("\n") |
|
66 | 39 | body = lines.map { |line| " #{line}" }.join("\n") |
67 | 40 | gitlog.puts body |
68 | 41 | end |
| 42 | +# Abort if there is no gem change |
| 43 | +abort("No gem changes since version #{old_version}!") if gitlog.empty? |
| 44 | + |
69 | 45 | gitlog.close |
70 | 46 |
|
71 | 47 | # Edit the gitlog? |
72 | | -Scripty.file_edit?('Gitlog', gitlog.path) |
| 48 | +edit_file?(gitlog.path, 'Gitlog') |
73 | 49 |
|
74 | 50 | # Prepare the .github/latest_release_body.md file |
75 | 51 | # Used by .github/workflows/create_release.yml which is triggered by the :rubygem_release task (push tag) |
76 | 52 | release_body_path = '.github/latest_release_body.md' |
77 | | -# Insert whats_new from the README into latest_release_body file |
78 | | -whats_new_content = Scripty.tagged_extract('README.md', 'whats_new') |
79 | | -Scripty.tagged_file_sub(release_body_path, 'whats_new', whats_new_content) |
| 53 | +# Copy the whats_new from the README to the latest_release_body file |
| 54 | +whats_new_content = extract_section_from_file('README.md', 'whats_new') |
| 55 | +replace_section_in_file(release_body_path, 'whats_new', whats_new_content) |
80 | 56 |
|
81 | | -# Insert the changes into latest_release_body file |
| 57 | +# Insert the changes into the latest_release_body file |
82 | 58 | changes = File.read(gitlog.path) |
83 | | -Scripty.tagged_file_sub(release_body_path, 'changes', changes) |
| 59 | +replace_section_in_file(release_body_path, 'changes', changes) |
84 | 60 |
|
85 | | -# Edit the Rlease Body? |
86 | | -Scripty.file_edit?('Release Body', release_body_path) |
| 61 | +# Edit the Release Body? |
| 62 | +edit_file?(release_body_path, 'Release Body') |
87 | 63 |
|
88 | 64 | # Update the CHANGELOG |
89 | | -Scripty.file_sub('CHANGELOG.md', /<hr>\n/, "<hr>\n\n## Version #{new_version}\n\n#{changes}") |
| 65 | +replace_string_in_file('CHANGELOG.md', /<hr>\n/, "<hr>\n\n## Version #{new_version}\n\n#{changes}") |
| 66 | + |
| 67 | +# Bump the version in files |
| 68 | +%w[retype.yml |
| 69 | + .github/ISSUE_TEMPLATE/Code.yml |
| 70 | + .github/latest_release_body.md |
| 71 | + gem/apps/calendar.ru |
| 72 | + gem/apps/demo.ru |
| 73 | + gem/apps/rails.ru |
| 74 | + gem/apps/repro.ru |
| 75 | + gem/bin/pagy |
| 76 | + gem/config/pagy.rb |
| 77 | + gem/lib/pagy.rb |
| 78 | + gem/pagy.gemspec |
| 79 | + src/pagy.ts].each do |path| |
| 80 | + replace_string_in_file(path, old_version, new_version) |
| 81 | +end |
| 82 | + |
| 83 | +# Bumps docs example |
| 84 | +replace_string_in_file('quick-start.md', |
| 85 | + old_version.split('.')[0, 2].join('.'), |
| 86 | + new_version.split('.')[0, 2].join('.')) |
| 87 | + |
| 88 | +# Build javascript files |
| 89 | +system(Scripty::ROOT.join('src/build').to_s) |
90 | 90 |
|
91 | 91 | # Run the test to check the consistency of versioning across files |
92 | 92 | system('bundle exec rake test_version') |
93 | 93 |
|
94 | 94 | # Optional update of top 100 |
95 | | -Scripty.ask_and_do('Do you want to update the "Top 100 contributors"? (y/n)> ') do |
| 95 | +confirm_to('update the "Top 100 contributors"') do |
96 | 96 | require_relative 'update_top100' |
97 | 97 | end |
98 | 98 |
|
99 | 99 | # Optional commit |
100 | | -Scripty.ask_and_do('Do you want to commit the changes? (y/n)> ') do |
| 100 | +confirm_to('commit the changes') do |
101 | 101 | system('git add -A') |
102 | 102 | system("git commit -m 'Version #{new_version}'") |
103 | 103 | end |
0 commit comments