travis-build-tools 1.0.30.0 → 2.0.38.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Njg3ODgyOGQwNWJkNDQyY2FkNTM4OTJiMjYxOThiZmRhMDlkMDE5NQ==
4
+ MWQ4MTc0NWJlMjFmODI3MjgwMmFkMTE4YzhhODAzY2ZkNzcyNmU0YQ==
5
5
  data.tar.gz: !binary |-
6
- NTk3ZDI3MTFlMTYzMmZmMTAxZDM4NzQ5NDYwYjMyYzRkZTI2YTEwZA==
6
+ ZjdmMmI2NWI0ZTc5MTAwY2Q4NGU1NzUxNzYzYWEyYWQ3YWZhNjBlZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTYzOWY4NjNmNzc4MGYzMTc4Yzk3MDIzY2U2M2M2OWMxOTczZDFhZTczY2I2
10
- NmVkYmViNGIyNzdiMzVmNDU3N2I0MDIxMDEzN2ZkN2ZiNDFmOTRmODRmNjg2
11
- ZWUwODllMmMxZTRhZWU3NmZmZTgwYzlmYmIxNmI2OTUzMzBhMjI=
9
+ NmI5MWY3MjQ4ZjgxMmFiZGMzMmVhMjJkY2NhMWEzODI4ZmVjNTE1ODdlNmI4
10
+ OWU2YmQ5MmNmOTg3Y2ZhZWVjYzdmMGZlMDBiMzRlMDhiYWM0ODljM2NjMDQ2
11
+ NmVmZjMyN2U5OTIzNjBmYzVmMzEyNmUyMTM3ZDM4NmJhNWQ1YzQ=
12
12
  data.tar.gz: !binary |-
13
- YzM2YTUxYzFlYmFmOTJhMWYwYWZkMmRhOThjNzQ2NmUzZDY3Yjg5MzI1ZWVl
14
- NjNlYjQ1ZjQ0ZWI0NjdkYTI4OGVlMTI0OTMwNTZmOGJlMWZhMTQ3NjM4ODRj
15
- OTAyYTViYWNiOWNkYzhhNjVmYTAwMjU5ODcxYjAwM2IxYWM5NjU=
13
+ YzQ0MmMxNGY4OTkzMDU2MjI5ZTRjZmMxYjhlZGY3YzRkMDZkYTQ1YzFmNzkz
14
+ MTE4ZmJlZTc4YWJkMGQ4NzE3NTE3YTg4MzEyNmQ3ODZkYzg0ZmUzZGEwNTgz
15
+ NzVmYTYzYTI3MDNmZjNiN2YyODg2MGYzMTdmZWY5NTUwMTgzMzA=
@@ -0,0 +1,50 @@
1
+ module TravisBuildTools
2
+ class Builder
3
+ def initialize(service_user, git_repository = nil)
4
+ @service_user = service_user
5
+ origin_url = %x[git config --get remote.origin.url]
6
+ @git_repository = git_repository || origin_url.split('://')[1] || origin_url.split('@')[1]
7
+
8
+ raise 'git_repository is not specified' if !@git_repository
9
+ raise 'service_user is not specified' if !@service_user
10
+ end
11
+
12
+ def publish_git_tag(tag_name)
13
+ if ENV['TRAVIS'] && ENV['TRAVIS_PULL_REQUEST'].match(/false/i)
14
+ raise 'tag_name is not specified' if !tag_name
15
+
16
+ #Setup up deploy
17
+ puts %x[git config --global user.email "builds@travis-ci.com"]
18
+ puts %x[git config --global user.name "Travis CI"]
19
+ puts %x[git tag #{tag_name} -a -m "Generated tag from TravisCI."]
20
+ puts "Pushing Git tag #{tag_name}."
21
+
22
+ %x[git push --tags --quiet https://#{@service_user}@#{@git_repository} #{tag_name} > /dev/null 2>&1]
23
+ end
24
+ end
25
+
26
+ def merge_downstream(release_branch_name, master_branch_name)
27
+ if ENV['TRAVIS'] && ENV['TRAVIS_PULL_REQUEST'].match(/false/i)
28
+ #get all branches
29
+ branches = %x[git ls-remote --heads origin].scan(/^.*refs\/heads\/(.*)$/).flatten
30
+ matching_branches = branches.select{|b| b.match(/#{Regexp.quote(release_branch_name)}/)}
31
+
32
+ #If this branch doesn't match the downstream then ignore creating the merge
33
+ return if !matching_branches.include?(ENV['TRAVIS_BRANCH'])
34
+
35
+ #Sort the branches by the match that comes after the release branch name
36
+ sorted_branches = matching_branches.map{|b| Gem::Version.new(b.match(/#{Regexp.quote(release_branch_name)}(.*)$/)[1].strip)}
37
+
38
+ #Find the next branch in the array that isn't the current branch
39
+ current_release_version = Gem::Version.new(ENV['TRAVIS_BRANCH'].match(/#{Regexp.quote(release_branch_name)}(.*)$/)[1].strip)
40
+ next_branch_to_merge = (sorted_branches.drop_while{|b| b <= current_release_version}.map{|v| release_branch_name + v.to_s} + ['master']).first
41
+
42
+ #create a merge commit for that branch
43
+ puts %x[git merge --no-ff origin/#{next_branch_to_merge}]
44
+ puts "Merging to downstream branch: #{next_branch_to_merge}"
45
+ #push origin for that branch using the service user
46
+ %x[git push --quiet https://#{@service_user}@#{@git_repository} HEAD:#{next_branch_to_merge} > /dev/null 2>&1]
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,35 +1,4 @@
1
1
  module TravisBuildTools
2
2
  module DSL
3
- def publish_git_tag(*args, &block)
4
- PublishGitTagTask.define_task(*args, &block)
5
- end
6
- end
7
-
8
- class PublishGitTagTask < Rake::Task
9
- attr_accessor :service_user
10
- attr_accessor :tag_name
11
- attr_accessor :git_repository
12
-
13
- def initialize(task_name, app)
14
- super(task_name, app)
15
- end
16
-
17
- def execute(args=nil)
18
- super(args)
19
-
20
- if ENV['TRAVIS'] && ENV['TRAVIS_PULL_REQUEST'].match(/false/i)
21
- raise 'service_user is not specified' if !@service_user
22
- raise 'tag_name is not specified' if !@tag_name
23
- raise 'git_repository is not specified' if !@git_repository
24
-
25
- #Setup up deploy
26
- puts %x[git config --global user.email "builds@travis-ci.com"]
27
- puts %x[git config --global user.name "Travis CI"]
28
- puts %x[git tag #{tag_name} -a -m "Generated tag from TravisCI."]
29
- puts "Pushing Git tag #{tag_name}."
30
-
31
- %x[git push --tags --quiet https://#{service_user}@#{git_repository} #{tag_name} > /dev/null 2>&1]
32
- end
33
- end
34
3
  end
35
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-build-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.30.0
4
+ version: 2.0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Parad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -62,6 +62,7 @@ extra_rdoc_files: []
62
62
  files:
63
63
  - lib/travis-build-tools.rb
64
64
  - lib/travis-build-tools/build.rb
65
+ - lib/travis-build-tools/builder.rb
65
66
  - lib/travis-build-tools/dsl.rb
66
67
  - lib/travis-build-tools/zip_file_generator.rb
67
68
  homepage: https://github.com/wparad/Travis-Build-Tools