Sha256: a4db35e98165e8ac225a42baf1d20456720ffae38ecaa5c817d03d1a9ae395b1

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

require 'fileutils'

module Radius
  module Toolbelt

    class ReleaseRepo
      include Rake::DSL

      attr_reader :repo, :ver, :dir, :files
      def initialize(repo, ver, dir, files)
        @repo = repo
        @dir = dir
        @ver = ver
        @files = files
      end

      def run
        puts "Releasing to repo in #{dir}"
        checkout
        copy
        tag_commit_push
      end

      private

      def checkout
        if File.exists? "#{dir}/.git"
          FileUtils.chdir dir do
            sh "git checkout master --quiet"
            sh "git reset --hard origin/master"
          end
        else
          system "git clone --depth 1 git@github.com:#{repo}.git #{dir}"
        end
      end

      def copy
        files.each do |src|
          dest = File.join dir, File.basename(src)
          FileUtils.copy_entry(src, dest, false, false, true)
        end
      end

      def tag_commit_push
        FileUtils.chdir dir do
          sh "git add ."
          sh "git commit -m 'Version #{ver}'"
          sh "git tag v#{ver}"
          sh "git push origin master --tags"
        end
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
radius-toolbelt-0.0.7 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.6 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.5 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.4 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.3 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.2 lib/radius/toolbelt/release_repo.rb
radius-toolbelt-0.0.1 lib/radius/toolbelt/release_repo.rb