We use the wonderful semantic versioning paradigm when versioning our rails app. One question I had was where is it best to store this number? I\'ve seen it stored in /l
In Rails 4, @fearless_fool's rake task above needs to look like this:
desc "create VERSION. Use MAJOR_VERSION, MINOR_VERSION, BUILD_VERSION to override defaults"
task :create_version do
version_file = "#{Rails.root}/config/initializers/version.rb"
major = ENV["MAJOR_VERSION"] || 1
minor = ENV["MINOR_VERSION"] || 0
build = ENV["BUILD_VERSION"] || `git describe --always --tags`
version_string = "VERSION = #{[major.to_s, minor.to_s, build.strip]}\n"
File.open(version_file, "w") {|f| f.print(version_string)}
$stderr.print(version_string)
end
The desc
line must be present and must come before the task :create...
line in order for rake to recognize it.