3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitにリリースタグを打つRakeタスク

Posted at

Rakeから「年月日.その日のリリースカウント」なるリリース用のGitタグを打ちます。
Rubyは初めて触るので、もっといい方法があるかも……。

require "open3"
require "time"

task :add_release_tag do
  day = Time.now.strftime("%Y%m%d")
  ver = 0
  tag = "#{day}.#{ver}"
  while Open3.capture3("git show #{tag}")[2].exitstatus == 0
    ver += 1
    tag = "#{day}.#{ver}"
  end

  `git tag -a #{tag} -m "release tag by rake"`
  `git push #{ENV["REMOTE_REPOGITORY"]} --tags`
end

リリース時に行う他のタスクと纏めておくと良い感じ。

task :release => [:prepare, :deploy, :add_release_tag]
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?