From 2dcbd2d3f107bdbf7388ddc327196f193de30ee2 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 28 Mar 2019 14:42:08 +0100 Subject: [PATCH 1/2] Release from GitLab CI Allowing the release to happen from CI cuts the dependency on the local setup of a developer. Freeing their time and resources. --- .gitlab-ci.yml | 9 ++ Makefile | 4 +- _support/release | 95 ++++++++------------ changelogs/unreleased/zj-release-from-ci.yml | 5 ++ doc/PROCESS.md | 18 ++-- 5 files changed, 57 insertions(+), 74 deletions(-) create mode 100644 changelogs/unreleased/zj-release-from-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9399c07679..7804aff0214 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.5-golang-1.11-g stages: - build - test + - release - publish variables: @@ -170,6 +171,14 @@ docker-tag: only: - tags@gitlab-org/gitaly +release: + stage: release + script: + - _support/release + only: + variables: + - $GITALY_VERSION + # Create a MR in GitLab-CE when releasing a Gitaly version update-downstream-server-version: stage: publish diff --git a/Makefile b/Makefile index 3772a585bd3..94794569eb2 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ all: build .PHONY: build build: prepare-build - cd $(BUILD_DIR) && $(MAKE) install INSTALL_DEST_DIR=$(CURDIR) + cd $(BUILD_DIR) && $(MAKE) install INSTALL_DEST_DIR=$(CURDIR) .PHONY: install install: prepare-build @@ -42,7 +42,7 @@ prepare-tests: prepare-build .PHONY: test test: prepare-build cd $(BUILD_DIR) && $(MAKE) $@ - + .PHONY: test-with-proxies test-with-proxies: prepare-build cd $(BUILD_DIR) && $(MAKE) $@ diff --git a/_support/release b/_support/release index 2ff2061e056..7f37766dace 100755 --- a/_support/release +++ b/_support/release @@ -1,80 +1,55 @@ #!/usr/bin/env ruby -require 'erb' +require 'net/http' +require 'json' require_relative 'run.rb' -REMOTE_REGEX = %r{gitlab.com.gitlab-org/gitaly.git} - -# Sanity check -%w[ - git@gitlab.com:gitlab-org/gitaly.git - https://gitlab.com/gitlab-org/gitaly.git - https://janedoe@gitlab.com/gitlab-org/gitaly.git -].each do |remote| - abort "regex check failed failed for #{remote.inspect}" unless REMOTE_REGEX.match(remote) -end - def main(version) - remote = capture!(%w[git remote get-url --push origin]) - unless REMOTE_REGEX.match(remote) - abort "Git remote 'origin' must match #{REMOTE_REGEX}, got #{remote.inspect}" - end - - unless version =~ /^[0-9]/ + unless version =~ /\A\d+\.\d+\.\d+\z/ abort "Version string #{version.inspect} does not look like a semver (e.g. \"1.0.2\"). Aborting." end - run!(%w[make verify]) - run!(%w[make clean test]) - - puts 'Testing for changed files' - run!(%w[git diff --quiet --exit-code]) - - puts 'Testing for staged changes' - run!(%w[git diff --quiet --cached --exit-code]) - - tag_name = "v#{version}" - write_version_file(version) - run!(%W[_support/generate_changelog #{version}]) - run!(%w[git add changelogs CHANGELOG.md]) + puts "Generated changelog for #{version}" - version_msg = "Version #{version}" - run!(%W[git commit -m #{version_msg}]) - run!(%W[git tag -a -m #{version_msg} #{tag_name}]) + actions = [ + { action: "update", file_path: "VERSION", content: version }, + { action: "update", file_path: "CHANGELOG.md", content: File.read("CHANGELOG.md") }, + ] - # We use 'capture!' to prevent 'git show' from invoking 'less'. - show_output = capture!(%W[git show --pretty #{tag_name}]) - puts show_output + Dir["changelogs/unreleased/*.yml"].each do |file| + actions << { action: 'delete', file_path: file } + end - puts "Proceed to publish version #{version}? Enter 'Yes' to continue; Ctrl-C to abort" - $stdout.flush - abort unless $stdin.gets.chomp == 'Yes' + commit_url = File.join(ENV['CI_API_V4_URL'], "projects", ENV['CI_PROJECT_ID'], "repository", "commits") + commit = post_api_request(commit_url, branch: ENV['CI_COMMIT_REF_NAME'], commit_message: "Version #{version}", actions: actions) + puts "Commited the new version to #{ENV['CI_COMMIT_REF_NAME']}" - run!(%W[git push origin HEAD #{tag_name}]) + tag_name = "v#{version}" + tag_url = File.join(ENV['CI_API_V4_URL'], "projects", ENV['CI_PROJECT_ID'], "repository", "tags") + post_api_request(tag_url, tag_name: tag_name, ref: commit[:id], message: "Version #{version}") + puts "Created a new tag: #{tag_name}" end -def write_version_file(version) - version_file = 'VERSION' - open(version_file, 'w') { |f| f.puts version } - run!(%W[git add #{version_file}]) -end +def post_api_request(url, body) + uri = URI.parse(url) -def error(msg) - warn "#{$0}: #{msg}" -end + header = { + 'Content-Type': 'application/json', + 'PRIVATE-TOKEN': ENV['GITLAB_TOKEN'] + } -unless ARGV.count == 1 - warn "Usage: #{$0} VERSION" - warn "Specify version as x.y.z" - abort -end + 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}" if (400..599).member?(Integer(response.code)) -directory_current_file = File.expand_path('..', __FILE__) -git_root_current_file = capture!(%w[git rev-parse --show-toplevel], directory_current_file).chomp -unless git_root_current_file == Dir.pwd - error "#{$0}: this script must be run from the root of the Gitaly repository" - abort + JSON.parse(response.body) + end end -main(ARGV.first) +abort("Releases must happen from GitLab CI") unless ENV["GITLAB_CI"] + +main(ENV['GITALY_VERSION']) diff --git a/changelogs/unreleased/zj-release-from-ci.yml b/changelogs/unreleased/zj-release-from-ci.yml new file mode 100644 index 00000000000..2feec106bab --- /dev/null +++ b/changelogs/unreleased/zj-release-from-ci.yml @@ -0,0 +1,5 @@ +--- +title: Release from GitLab CI +merge_request: 1159 +author: +type: other diff --git a/doc/PROCESS.md b/doc/PROCESS.md index b68bc7a68b5..37602d39925 100644 --- a/doc/PROCESS.md +++ b/doc/PROCESS.md @@ -19,20 +19,14 @@ counter. #### Creating a release - Pick a release number (x.y.z) -- Check out the master branch on your local machine -- run `_support/release x.y.z` +- Go to the [new pipelines page](https://gitlab.com/gitlab-org/gitaly/pipelines/new) +- Select the correct branch to release from, usually `master` or `*-*-stable`. +- Set GITALY_VERSION to the release number, and click 'Create pipeline'. -Where x.y.z is a semver-compliant version number. +Where x.y.z is a semver-compliant version number, without leading `v`. -- To automatically create a merge-request in Gitlab CE to update that - project to the latest tag, run - -```shell -GITLAB_TOKEN=$(cat /path/to/gitlab-token) _support/update-downstream-server-version -``` - -- This will create a merge-request (with changelog) and assign it to you. Once the build has - completed successfully, assign it to a maintainer for review. +To bump the version on GitLab-CE a merge request will be created, with changelog, +which will be assigned to you. ## Experimental builds -- GitLab From 76d048dcfa753601c2396233e350c5fc1845a3ce Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Fri, 5 Apr 2019 14:34:18 +0000 Subject: [PATCH 2/2] Version 123.123.124 --- CHANGELOG.md | 13 +++++++++++++ VERSION | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a41d315942c..cbb3fc3fb79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Gitaly changelog +## v123.123.124 + +#### Other +- Release from GitLab CI + https://gitlab.com/gitlab-org/gitaly/merge_requests/1159 +- Always use overlay2 storage driver on Docker build + https://gitlab.com/gitlab-org/gitaly/merge_requests/1148 + Contributed by Takuya Noguchi + +#### Removed +- Drop support for Golang 1.10 + https://gitlab.com/gitlab-org/gitaly/merge_requests/1149 + ## v1.30.0 #### Added diff --git a/VERSION b/VERSION index 034552a83ee..a9b1deb92d3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.30.0 +123.123.124 \ No newline at end of file -- GitLab