Stefan Saasen avatar Stefan Saasen committed d0c12a0

Add task to bump the version properly

Comments (0)

Files changed (1)

logparser/Rakefile

   end
 end
 
+desc "Update version to the next minor version, tag the result"
+task :bump_minor_version do
+  current_version = `git describe --tags`.strip.split("-").first.gsub(/^v/, '')
+  major, minor = current_version.split(".").map {|e| e.to_i}
+  next_version = [major, minor.next].join(".")
+
+  # Update version in Main
+  update_file(File.join("src", "Main.hs"), /appVersion = "[^"]+"/, "appVersion = \"#{next_version}\"")
+
+  # Update cabal file
+  update_file("logparser.cabal", /^version:.*$/, "version:                #{next_version}")
+
+  # Commit and tag
+  msg = "Bump version to #{next_version}"
+  puts msg
+  `git add -u`
+  `git commit -m "#{msg}"`
+  `git tag -a -m "#{msg}" v#{next_version}`
+end
+
 def version
   `git describe --tag --always`.strip
 end
 ensure
   rm_r name
 end
+
+
+def update_file(file, pattern, replace)
+  updated = IO.read(file)
+  File.open(file, "w") do |f|
+    f << updated.gsub(pattern, replace)
+  end
+end
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.