Sha256: d5752e1a4badb24c2f4db30c3fd60ff2786b8667a48520fd2a66c161a0496bd0

Contents?: true

Size: 1.88 KB

Versions: 29

Compression:

Stored size: 1.88 KB

Contents

Capistrano::Configuration.instance(:must_exist).load do
  define_recipe :release_tagger do |*stages|
    # Set up some default stages
    set :autotagger_stages, stages.flatten unless exists?(:autotagger_stages)  && !stages.empty?
    
    # This needs to be loaded after the stages are set up
    require 'release_tagger'
    
    set :keep_release_tags, 5 unless exists?(:keep_release_tags)
    namespace :release_tagger do
      desc "remove old tags, similar to keep_releases"
      task :remove_previous_tags, :roles => :app do
        keep_tags = fetch(:keep_release_tags, 5)
        tags = `git tag`
        tags = tags.split
        stage_tags = {}
        tags.each do |tag|
          stage = tag.split('/').first
          stage_tags[stage] = [] unless stage_tags.key?(stage)
          stage_tags[stage] << tag
        end

        stage_tags.each do |stage, tags|
          # remove all tags but the last n number
          tags[0..-(keep_tags + 1)].each do |tag|
            puts `git tag -d #{tag}`
            puts `git push origin :refs/tags/#{tag}`
          end
        end
      end
      
      desc "remove all local stage tags before release_tagger fetches all tags"
      task :remove_local_stage_tags, :roles => :app do
        autotagger_stages.each do |stage|
          puts `git tag -l #{stage}/* | xargs git tag -d` 
        end if fetch(:perform_remove_local_stage_tags, true)
      end
    end
    
    # Run release tagger to get the right release for the deploy
    before  "deploy:update_code", "release_tagger:remove_local_stage_tags"
    before  "deploy:update_code", "release_tagger:set_branch"
    
    before  "deploy:cleanup",     "release_tagger:create_tag"
    before  "deploy:cleanup",     "release_tagger:write_tag_to_shared"
    before  "deploy:cleanup",     "release_tagger:remove_previous_tags"
    before  "deploy:cleanup",     "release_tagger:print_latest_tags"
    
    
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
factorylabs-fdlcap-0.3.10 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.11 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.15 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.16 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.17 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.18 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.19 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.20 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.21 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.23 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.24 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.25 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.26 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.27 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.28 lib/fdlcap/recipes/autotagger.rb
factorylabs-fdlcap-0.3.9 lib/fdlcap/recipes/autotagger.rb
fdlcap-0.4.6 lib/fdlcap/recipes/autotagger.rb
fdlcap-0.4.5 lib/fdlcap/recipes/autotagger.rb
fdlcap-0.4.4 lib/fdlcap/recipes/autotagger.rb
fdlcap-0.4.3 lib/fdlcap/recipes/autotagger.rb