Skip to content

Commit

Permalink
Bump the version inside the metadata instead of gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
hadiidbouk committed Jul 8, 2024
1 parent 159c4c7 commit 0be203a
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'English'
require 'rake/testtask'
require 'rake/packagetask'
require_relative 'lib/autosparkle/metadata'

############# Common #############
desc 'Build the gem'
Expand All @@ -11,11 +12,6 @@ task :build do
raise 'Gem build failed' unless $CHILD_STATUS.success?
end

def retrieve_gem_version
gemspec_content = File.read('autosparkle.gemspec')
gemspec_content.match(/spec\.version\s*=\s*['"]([^'"]+)['"]/)[1]
end

############# CI #############
desc 'Check Ruby files for syntax errors'
task :syntax do
Expand Down Expand Up @@ -45,14 +41,11 @@ task :bump_version do
method = ENV.fetch('METHOD', nil)
raise 'You must specify the method (major, minor, patch)' unless method

# Read the gemspec file
gemspec_file = 'autosparkle.gemspec'
gemspec_content = File.read(gemspec_file)
metadata_file_path = 'lib/autosparkle/metadata.rb'
metadata_content = File.read(metadata_file_path)

new_version = nil

# Update the version line
new_gemspec_content = gemspec_content.gsub(/(spec\.version\s*=\s*['"])([^'"]+)(['"])/) do
new_metadata_content = metadata_content.gsub(/(VERSION = ')([^']+)(')/) do
prefix = Regexp.last_match(1)
current_version = Regexp.last_match(2)
suffix = Regexp.last_match(3)
Expand All @@ -75,10 +68,9 @@ task :bump_version do
"#{prefix}#{new_version}#{suffix}"
end

# Write the updated content back to the file
File.write(gemspec_file, new_gemspec_content)
File.write(metadata_file_path, new_metadata_content)

puts "Bumped version to #{new_version}"
puts "Version updated to #{new_version}"
end

desc 'Push the new version to the repository'
Expand All @@ -91,7 +83,7 @@ task :push_version do
system 'git pull origin develop'
system 'git checkout develop'
system 'git add autosparkle.gemspec'
system "git commit -m 'Bump version to #{retrieve_gem_version}'"
system "git commit -m 'Bump version to #{Autosparkle::VERSION}'"
system 'git push origin develop'

# Retreive the last commit hash
Expand Down

0 comments on commit 0be203a

Please sign in to comment.