Skip to content

Commit 12a106b

Browse files
committed
[CI] Adds make.sh script to publish artifacts in docker container
1 parent a81ab86 commit 12a106b

File tree

7 files changed

+101
-10
lines changed

7 files changed

+101
-10
lines changed

.ci/make.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# parameters are available to this script
3+
4+
# common build entry script for all elasticsearch clients
5+
6+
# ./.ci/make.sh bump VERSION
7+
# ./.ci/make.sh release TARGET_DIR
8+
script_path=$(dirname "$(realpath -s "$0")")
9+
repo=$(realpath "$script_path/../")
10+
11+
# shellcheck disable=SC1090
12+
CMD=$1
13+
VERSION=$2
14+
set -euo pipefail
15+
16+
TARGET_DIR=".ci/output"
17+
OUTPUT_DIR="$repo/${TARGET_DIR}"
18+
RUBY_TEST_VERSION=${RUBY_TEST_VERSION-2.7}
19+
20+
case $CMD in
21+
bump)
22+
TASK=bump["$VERSION"]
23+
;;
24+
build)
25+
TASK=build["$TARGET_DIR"]
26+
;;
27+
*)
28+
echo -e "\nUsage:\n\t $0 {bump[VERSION]|build[VERSION,TARGET_DIR]}\n"
29+
exit 1
30+
esac
31+
32+
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
33+
echo -e "\033[34;1mINFO:\033[0m RUBY_TEST_VERSION ${RUBY_TEST_VERSION}\033[0m"
34+
35+
echo -e "\033[1m>>>>> Build [elastic/elasticsearch-ruby container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
36+
37+
docker build --file .ci/Dockerfile --tag elastic/elasticsearch-ruby .
38+
39+
echo -e "\033[1m>>>>> Run [elastic/elasticsearch-ruby container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
40+
41+
mkdir -p "$OUTPUT_DIR"
42+
43+
docker run \
44+
--env "RUBY_TEST_VERSION" \
45+
--name test-runner \
46+
--volume "${OUTPUT_DIR}:/${TARGET_DIR}" \
47+
--rm \
48+
elastic/elasticsearch-ruby \
49+
bundle exec rake "$TASK"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Gemfile.lock
1212
*.log
1313
.idea/*
1414
profile/**/data/*.json
15+
.ci/output

Rakefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ RELEASE_TOGETHER = [ 'elasticsearch',
3636

3737
CERT_DIR = ENV['CERT_DIR'] || '.ci/certs'
3838

39+
# Import build task after setting constants:
40+
import 'rake_tasks/build_tasks.rake'
41+
3942
def admin_client
4043
$admin_client ||= begin
4144
transport_options = {}
@@ -130,7 +133,7 @@ desc <<-DESC
130133
131134
$ rake update_version[5.0.0,5.0.1]
132135
DESC
133-
task :update_version, :old, :new do |task, args|
136+
task :update_version, :old, :new do |_, args|
134137
require 'ansi'
135138

136139
puts '[!!!] Required argument [old] missing'.ansi(:red) unless args[:old]

elasticsearch-api/elasticsearch-api.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Gem::Specification.new do |s|
3939
s.test_files = s.files.grep(%r{^(test|spec|features)/})
4040
s.require_paths = ['lib']
4141

42-
s.extra_rdoc_files = [ 'README.md', 'LICENSE' ]
43-
s.rdoc_options = [ '--charset=UTF-8' ]
42+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
43+
s.rdoc_options = ['--charset=UTF-8']
4444

4545
s.required_ruby_version = '>= 2.4'
4646

elasticsearch-transport/elasticsearch-transport.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
3939
s.test_files = s.files.grep(%r{^(test|spec|features)/})
4040
s.require_paths = ['lib']
4141

42-
s.extra_rdoc_files = [ 'README.md', 'LICENSE' ]
42+
s.extra_rdoc_files = [ 'README.md', 'LICENSE.txt' ]
4343
s.rdoc_options = [ '--charset=UTF-8' ]
4444

4545
s.required_ruby_version = '>= 2.4'

elasticsearch/elasticsearch.gemspec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ Gem::Specification.new do |s|
3333
'source_code_uri' => 'https://github.com/elastic/elasticsearch-ruby/tree/7.x',
3434
'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-ruby/issues'
3535
}
36-
s.files = `git ls-files`.split($/)
37-
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
38-
s.executables << 'elastic_ruby_console'
39-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
36+
s.files = `git ls-files`.split($/)
37+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
38+
s.executables << 'elastic_ruby_console'
39+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
4040
s.require_paths = ['lib']
4141
s.bindir = 'bin'
4242

43-
s.extra_rdoc_files = [ 'README.md', 'LICENSE' ]
44-
s.rdoc_options = [ '--charset=UTF-8' ]
43+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
44+
s.rdoc_options = ['--charset=UTF-8']
4545

4646
s.required_ruby_version = '>= 2.4'
4747

rake_tasks/build_tasks.rake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
# Licensed to Elasticsearch B.V. under one or more contributor
4+
# license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright
6+
# ownership. Elasticsearch B.V. licenses this file to you under
7+
# the Apache License, Version 2.0 (the "License"); you may
8+
# not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
require_relative '../elasticsearch/lib/elasticsearch/version.rb'
19+
CURRENT_VERSION = Elasticsearch::VERSION
20+
21+
desc 'Bump versions'
22+
task :bump, [:version] do |_, args|
23+
raise ArgumentError, 'You must specify a version: rake bump[8.0.0]' unless args[:version]
24+
25+
Rake::Task['update_version'].invoke(CURRENT_VERSION, args[:version])
26+
end
27+
28+
desc 'Build release gem files'
29+
task :build, [:output_dir] do |_, args|
30+
raise ArgumentError, 'You must specify an output dir: rake build[output_dir]' unless args[:output_dir]
31+
32+
RELEASE_TOGETHER.each do |gem|
33+
puts '-' * 80
34+
puts "Building #{gem} v#{CURRENT_VERSION} to #{args[:output_dir]}"
35+
sh "cd #{CURRENT_PATH.join(gem)} && gem build --silent && mv *.gem #{CURRENT_PATH.join(args[:output_dir])}"
36+
end
37+
puts '-' * 80
38+
end

0 commit comments

Comments
 (0)