Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2017-09-11 15:32:35 +0300
committerJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-09-11 15:32:35 +0300
commit22383855e441d1cfcee9529618e70fb27a35f426 (patch)
treeda1d37cd1af100da2d8cd862a0dc3ff5a33a8dfc
parent2ba31bd62551073380c7a3fe58b495f6a6c9d31d (diff)
Auto update downstream server version
-rw-r--r--.gitlab-ci.yml9
-rwxr-xr-x_support/update-downstream-server-version.rb61
2 files changed, 70 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index be4098735..963ff2206 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -105,3 +105,12 @@ codeclimate:
ruby-2.3-golang-1.8-git-2.8: *build_image
ruby-2.3-golang-1.8-git-2.13: *build_image
+
+# Create a MR in GitLab-CE when releasing a Gitaly version
+update-downstream-server-version:
+ stage: publish
+ only:
+ - tags
+ script:
+ - ruby _support/update-downstream-server-version.rb
+ allow_failure: true
diff --git a/_support/update-downstream-server-version.rb b/_support/update-downstream-server-version.rb
new file mode 100755
index 000000000..7733e5f36
--- /dev/null
+++ b/_support/update-downstream-server-version.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+
+require 'net/http'
+require 'uri'
+require 'json'
+
+def gitlab_api(url, body)
+ uri = URI.parse(url)
+
+ header = {
+ 'Content-Type': 'application/json',
+ 'PRIVATE-TOKEN': ENV['PRIVATE_TOKEN']
+ }
+
+ # Create the HTTP objects
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
+ request = Net::HTTP::Post.new(uri.request_uri, header)
+ request.body = body.to_json
+
+ response = http.request(request)
+ raise "Request to #{url} failed: #{response.body}" unless Integer(response.code) < 400
+ response.body
+ end
+end
+
+def update_tag(project_id, tag_version)
+ commit = {
+ "branch": "gitaly-version-#{tag_version}",
+ "start_branch": "master",
+ "commit_message": "Update Gitaly version to #{tag_version}",
+ "actions": [{
+ "action": "update",
+ "file_path": "GITALY_SERVER_VERSION",
+ "content": "#{tag_version}"
+ }]
+ }
+
+ gitlab_api("https://gitlab.com/api/v4/projects/#{project_id}/repository/commits", commit)
+end
+
+def create_mr(project_id, tag_version, assignee_id)
+ merge_request = {
+ "source_branch": "gitaly-version-#{tag_version}",
+ "target_branch": "master",
+ "title": "Upgrade Gitaly to #{tag_version}",
+ "assignee_id": assignee_id,
+ "description": "Upgrade Gitaly to #{tag_version}",
+ "labels": "Gitaly",
+ "remove_source_branch": true,
+ "squash": true
+ }
+
+ gitlab_api("https://gitlab.com/api/v4/projects/#{project_id}/merge_requests", merge_request)
+end
+
+project_id = ENV["GITLAB_CE_PROJECT_ID"]
+tag_version = ENV["CI_COMMIT_TAG"]
+assignee_id = ENV["GITLAB_USER_ID"]
+
+update_tag(project_id, tag_version)
+create_mr(project_id, tag_version, assignee_id)