LoginSignup
10
8

More than 5 years have passed since last update.

いい感じにgit flowを使ってリリース時にタグを打つ

Last updated at Posted at 2016-11-01

tl; dr

使う機能

  • git flow
  • git describe
  • version_up.sh
  • git config

git flow

http://danielkummer.github.io/git-flow-cheatsheet/index.ja_JP.html
↑これ見てね
って感じですが、GitLabとかでMergeRequestを作成していると、使わない機能もちらほら。。
その中でもgit flow releaseに関しては、とても使い勝手がいいので、これだけのために使ってます。

release

git flowでやるreleaseのフローは

  1. start [version]でreleaseブランチを作成。
  2. リリース用のゴニョゴニョする
  3. finish [version]でdevelopとかmasterにマージ、タグも付けちゃう

なのですが、finishのときに -p オプションをつけると、3.で作成したものを全部pushしてくれます。(1. でもしリモートブランチ作成していたらそれも消してくれます)

tagせっかく作ったのにpushしわすれてたーとか発生しません。

しかしながらコード長いのでエイリアスを貼っときます。

.gitconfig
frs = flow release start
frf = flow release finish -p

git describe

最新のタグを表示するものです。
もし現状のコミットが最新のタグから乖離しているばあいは、[tag]-[tagから現在までにコミットした回数]-[ハッシュ値]
となってしまい、辛い感じになってしまいます。

基本的に上記のフローでリリースをしているとmasterブランチは最新のタグの状態になっているはずなので

git describe master

とやってあげれば直近のタグのみを取得することができます。

version_up.sh

http://sinsoku.hatenablog.com/entry/2014/06/01/195735
こちら参考にさせていただきました。

echo 1.1.0 | version_up.sh [上げたいバージョン]ってやればバージョンアップしたバージョンを返してくれます。

バージョン番号はこのスクリプトだと[0-9\.]+しか対応しないので、それ以外の文字列を削除するスクリプトを挟んであげます。

.gitconfig
vup = !git describe master | sed 's/[^0-9\\.]//' | ~/.zsh/version_up.sh

gitconfig

言わずとしれた、gitコマンドのエイリアス設定ファイル。(まぁほかもあるけどね)}

下記を登録しています。 ( https://github.com/yuroyoro/dotfiles を参考にさせていただいております)

[alias]
  ff  = flow feature
  ffl = flow feature list
  ffs = flow feature start
  fff = flow feature finish
  ffc = flow feature checkout
  ffp = flow feature publish
  fr = flow release
  frs = flow release start
  frf = flow release finish -p
  fh  = flow hotfix
  fhl = flow hotfix list
  fhs = flow hotfix start
  fhf = flow hotfix finish
  fhp = flow hotfix publish
  fs  = flow support

全部まとめる

developブランチで

git frs `git vup bugfix`

でリリースブランチ作成

リリースブランチで

git frf `git vup bugfix`

でリリース終了

10
8
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
10
8