mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:19:52 +01:00
9413d23a02
this also allows the UseCase classes to be hot reloaded in dev 🎉
- remove use_case requires (except for the exporter as Zeitwerk
doesn't know about the subclasses)
- move version.rb to lib/retrospring so that Zeitwerk knows where
to find Retrospring::Version
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
namespace :version do
|
|
desc "Bump the version"
|
|
task bump: :environment do
|
|
puts "Current version: #{Retrospring::Version}"
|
|
current_ymd = %i[year month day].map { Retrospring::Version.public_send(_1) }
|
|
|
|
now = Time.now.utc
|
|
today_ymd = %i[year month day].map { now.public_send(_1) }
|
|
|
|
version_path = Rails.root.join("lib/retrospring/version.rb")
|
|
version_contents = File.read(version_path)
|
|
|
|
patch_contents = lambda do |key, val|
|
|
version_contents.sub!(/def #{key} = .+/) { "def #{key} = #{val}" }
|
|
end
|
|
|
|
if current_ymd == today_ymd
|
|
# bump the patch version
|
|
patch_contents[:patch, Retrospring::Version.patch + 1]
|
|
else
|
|
# set year/month/day to today, and reset patch to 0
|
|
%i[year month day].each { patch_contents[_1, now.public_send(_1)] }
|
|
patch_contents[:patch, 0]
|
|
end
|
|
|
|
# write the file
|
|
File.write(version_path, version_contents)
|
|
|
|
# reload the version file
|
|
load version_path
|
|
puts "New version: #{Retrospring::Version}"
|
|
end
|
|
|
|
desc "Commit and tag a new release"
|
|
task commit: :environment do
|
|
version_path = Rails.root.join("lib/retrospring/version.rb")
|
|
|
|
puts "Committing version"
|
|
sh %(git commit -m 'Bump version to #{Retrospring::Version}' -- #{version_path.to_s.inspect})
|
|
|
|
puts "Tagging new release"
|
|
sh %(git tag -a -m 'Bump version to #{Retrospring::Version}' #{Retrospring::Version})
|
|
end
|
|
|
|
desc "Update the version (bump + commit)"
|
|
task update: %i[bump commit]
|
|
end
|