holy moly

pangratz prattles

GitHub Dashboard #8

Goal of this iteration: Enhance :release task and use version from VERSION file

Currently the version defined in Dashboard.VERSION has to be updated manually. Well, this needs to changed. Therefore I created a file VERSION which contains the actual version of the code base. I also created a VersionFilter in the Assetfile which reads the version from VERSION and replaces all VERSION: 'x.y.z' with the actual version:

Assetfile
1
2
3
4
5
6
7
8
9
10
class VersionFilter < Filter
  def generate_output(inputs, output)
    version = File.read("VERSION").strip
    inputs.each do |input|
      result = input.read
      result.gsub!(/VERSION: '.*'/, "VERSION: '#{version}'")
      output.write(result)
    end
  end
end

I also enhanced the :release task of the Rakefile so it automatically deploys the current version of the dashboard, tags the current code base and bumps the version.

Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def version
  File.read("VERSION").strip
end

desc "Bumps current version"
task :bump_version do
  next_version = Versionomy.parse(version).bump(:tiny)

  print "Enter next version (#{next_version}): "
  user_input = STDIN.gets.chomp
  next_version = user_input unless user_input.empty?

  File.open('VERSION', 'w') { |f| f.write( next_version ) }
  system "git commit VERSION -m 'Bump to new version #{next_version}'"
end

desc "Tag current code with current version"
task :release => :deploy do
  system "git tag -a v#{version}"
  system "git push --tag"

  Rake::Task["bump_version"].invoke
end

Roundup

The changes in this post introduce an up to date Dashboard.VERSION as well as a more convenient :release task.

The result of this post’s changes are available at tag v0.0.8 (changes). As always, the result is deployed at code418.com/dashboard.

Comments