Where do you store your Rails Application's version number?

前端 未结 8 1735
终归单人心
终归单人心 2021-01-30 05:41

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

8条回答
  •  借酒劲吻你
    2021-01-30 05:58

    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.

提交回复
热议问题