on_strum-healthcheck 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +213 -0
  3. data/.circleci/gemspecs/compatible +25 -0
  4. data/.circleci/gemspecs/latest +33 -0
  5. data/.circleci/linter_configs/.bundler-audit.yml +4 -0
  6. data/.circleci/linter_configs/.commitspell.yml +30 -0
  7. data/.circleci/linter_configs/.cspell.yml +31 -0
  8. data/.circleci/linter_configs/.fasterer.yml +4 -0
  9. data/.circleci/linter_configs/.lefthook.yml +44 -0
  10. data/.circleci/linter_configs/.markdownlint.yml +9 -0
  11. data/.circleci/linter_configs/.rubocop.yml +137 -0
  12. data/.circleci/linter_configs/.yamllint.yml +7 -0
  13. data/.circleci/scripts/changeloglint.sh +22 -0
  14. data/.circleci/scripts/commitspell.sh +22 -0
  15. data/.circleci/scripts/release.sh +69 -0
  16. data/.circleci/scripts/set_publisher_credentials.sh +12 -0
  17. data/.codeclimate.yml +17 -0
  18. data/.github/BRANCH_NAMING_CONVENTION.md +36 -0
  19. data/.github/DEVELOPMENT_ENVIRONMENT_GUIDE.md +26 -0
  20. data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
  21. data/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
  22. data/.github/ISSUE_TEMPLATE/issue_report.md +32 -0
  23. data/.github/ISSUE_TEMPLATE/question.md +22 -0
  24. data/.github/PULL_REQUEST_TEMPLATE.md +49 -0
  25. data/.gitignore +11 -0
  26. data/.reek.yml +39 -0
  27. data/.rspec +2 -0
  28. data/.ruby-gemset +1 -0
  29. data/.ruby-version +1 -0
  30. data/CHANGELOG.md +9 -0
  31. data/CODE_OF_CONDUCT.md +74 -0
  32. data/CONTRIBUTING.md +48 -0
  33. data/Gemfile +5 -0
  34. data/LICENSE.txt +21 -0
  35. data/README.md +224 -0
  36. data/Rakefile +8 -0
  37. data/bin/console +15 -0
  38. data/bin/setup +8 -0
  39. data/lib/on_strum/healthcheck/configuration.rb +141 -0
  40. data/lib/on_strum/healthcheck/core.rb +22 -0
  41. data/lib/on_strum/healthcheck/error/configuration/argument_type.rb +15 -0
  42. data/lib/on_strum/healthcheck/error/configuration/enpoint_pattern.rb +15 -0
  43. data/lib/on_strum/healthcheck/error/configuration/http_status_failure.rb +15 -0
  44. data/lib/on_strum/healthcheck/error/configuration/http_status_success.rb +15 -0
  45. data/lib/on_strum/healthcheck/error/configuration/not_callable_service.rb +15 -0
  46. data/lib/on_strum/healthcheck/error/configuration/not_configured.rb +15 -0
  47. data/lib/on_strum/healthcheck/error/configuration/unknown_service.rb +15 -0
  48. data/lib/on_strum/healthcheck/rack_middleware.rb +28 -0
  49. data/lib/on_strum/healthcheck/resolver.rb +85 -0
  50. data/lib/on_strum/healthcheck/version.rb +7 -0
  51. data/lib/on_strum/healthcheck.rb +25 -0
  52. data/on_strum-healthcheck.gemspec +28 -0
  53. metadata +164 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 49506d15af7f2a697b464a09f7e8ee603545714e0461ad9e58438260fc90a19f
4
+ data.tar.gz: dbacd0cc9ed4983e964974ca669355f76173992aec19ab2e529a91dafea461f9
5
+ SHA512:
6
+ metadata.gz: 99be94127829f725b296eed4c2e33b0d9155227568a8e4365ed21ea396f015fb2fa425230546771eed395b3a17ca32ad863a5ecd2353021ac1f64ac74e8cfdff
7
+ data.tar.gz: 64889d09e6980042ab94b45d527a62828a768e3a51b74af6e1ec8c8a8e155142728b27bad1231fec29d543fdbaa84b9f9fcc90688b9b68550a05e1b79ee34ba6
@@ -0,0 +1,213 @@
1
+ ---
2
+
3
+ version: 2.1
4
+
5
+ defaults: &defaults
6
+ working_directory: ~/ruby-on-strum-healthcheck
7
+ docker:
8
+ - image: cimg/ruby:<< parameters.ruby-version >>
9
+
10
+ orbs:
11
+ ruby: circleci/ruby@2.1.1
12
+
13
+ references:
14
+ bundle_install: &bundle_install
15
+ run:
16
+ name: Installing gems
17
+ command: |
18
+ bundle config set --local path '~/vendor/bundle'
19
+ bundle install
20
+
21
+ install_linters: &install_linters
22
+ run:
23
+ name: Installing bunch of linters
24
+ command: |
25
+ curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash
26
+ sudo apt-get update -y
27
+ sudo apt-get install -y lefthook shellcheck yamllint
28
+ npm install --prefix='~/.local' --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli
29
+ cp .circleci/linter_configs/.fasterer.yml .fasterer.yml
30
+ cp .circleci/linter_configs/.lefthook.yml lefthook.yml
31
+
32
+ install_codeclimate_reporter: &install_codeclimate_reporter
33
+ run:
34
+ name: Installing CodeClimate test reporter
35
+ command: |
36
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
37
+ chmod +x ./cc-test-reporter
38
+
39
+ use_latest_bundler: &use_latest_bundler
40
+ run:
41
+ name: Using latest bundler
42
+ command: gem install bundler
43
+
44
+ use_latest_gemspec: &use_latest_gemspec
45
+ run:
46
+ name: Using latest gemspec
47
+ command: cp .circleci/gemspecs/latest on_strum-healthcheck.gemspec
48
+
49
+ use_compatible_gemspec: &use_compatible_gemspec
50
+ run:
51
+ name: Using compatible gemspec
52
+ command: cp .circleci/gemspecs/compatible on_strum-healthcheck.gemspec
53
+
54
+ jobs:
55
+ linters-ruby:
56
+ parameters:
57
+ ruby-version:
58
+ type: string
59
+
60
+ <<: *defaults
61
+
62
+ steps:
63
+ - checkout
64
+
65
+ - <<: *use_latest_bundler
66
+ - <<: *use_latest_gemspec
67
+ - <<: *bundle_install
68
+ - <<: *install_linters
69
+
70
+ - run:
71
+ name: Running commit linters
72
+ command: lefthook run commit-linters
73
+
74
+ - run:
75
+ name: Running code style linters
76
+ command: lefthook run code-style-linters
77
+
78
+ - run:
79
+ name: Running code performance linters
80
+ command: lefthook run code-performance-linters
81
+
82
+ - run:
83
+ name: Running code vulnerability linters
84
+ command: lefthook run code-vulnerability-linters
85
+
86
+ - run:
87
+ name: Running code documentation linters
88
+ command: lefthook run code-documentation-linters
89
+
90
+ - run:
91
+ name: Running release linters
92
+ command: lefthook run release-linters
93
+
94
+ tests-ruby:
95
+ parameters:
96
+ ruby-version:
97
+ type: string
98
+
99
+ <<: *defaults
100
+
101
+ steps:
102
+ - checkout
103
+
104
+ - <<: *use_latest_bundler
105
+ - <<: *use_latest_gemspec
106
+ - <<: *bundle_install
107
+ - <<: *install_codeclimate_reporter
108
+
109
+ - run:
110
+ name: Running RSpec
111
+ command: |
112
+ ./cc-test-reporter before-build
113
+ bundle exec rspec
114
+
115
+ - run:
116
+ name: Creating CodeClimate test coverage report
117
+ command: |
118
+ ./cc-test-reporter format-coverage -t simplecov -o "coverage/codeclimate.$CIRCLE_NODE_INDEX.json"
119
+
120
+ - store_artifacts:
121
+ name: Saving Simplecov coverage artifacts
122
+ path: ~/ruby-on-strum-healthcheck/coverage
123
+ destination: coverage
124
+
125
+ - deploy:
126
+ name: Uploading CodeClimate test coverage report
127
+ command: |
128
+ ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
129
+
130
+ compatibility-ruby:
131
+ parameters:
132
+ ruby-version:
133
+ type: string
134
+
135
+ <<: *defaults
136
+
137
+ steps:
138
+ - checkout
139
+
140
+ - <<: *use_compatible_gemspec
141
+
142
+ - ruby/install-deps:
143
+ bundler-version: "2.3.26"
144
+ with-cache: false
145
+ path: '~/vendor/custom_bundle'
146
+
147
+ - run:
148
+ name: Running compatibility tests
149
+ command: bundle exec rspec
150
+
151
+ rubygems-deps-ruby:
152
+ parameters:
153
+ ruby-version:
154
+ type: string
155
+
156
+ <<: *defaults
157
+
158
+ steps:
159
+ - checkout
160
+
161
+ - run:
162
+ name: Building rubygems dependencies from default gemspec on minimal Ruby version
163
+ command: bundle install
164
+
165
+ releasing-gem-from-ruby:
166
+ parameters:
167
+ ruby-version:
168
+ type: string
169
+
170
+ <<: *defaults
171
+
172
+ steps:
173
+ - checkout
174
+
175
+ - add_ssh_keys:
176
+ fingerprints:
177
+ - "SHA256:eJhlVtu2gws5rDavHcqZ5GJF/aS8kCctMprdC+Twlns"
178
+
179
+ - run:
180
+ name: Publishing new release
181
+ command: ./.circleci/scripts/release.sh
182
+
183
+ workflows:
184
+ build_test_deploy:
185
+ jobs:
186
+ - linters-ruby:
187
+ matrix:
188
+ parameters:
189
+ ruby-version: ["3.3-node"]
190
+ - tests-ruby:
191
+ matrix:
192
+ parameters:
193
+ ruby-version: ["3.3"]
194
+ - compatibility-ruby:
195
+ matrix:
196
+ parameters:
197
+ ruby-version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2"]
198
+ - rubygems-deps-ruby:
199
+ matrix:
200
+ parameters:
201
+ ruby-version: ["2.5"]
202
+ - releasing-gem-from-ruby:
203
+ requires:
204
+ - linters-ruby
205
+ - tests-ruby
206
+ - compatibility-ruby
207
+ - rubygems-deps-ruby
208
+ matrix:
209
+ parameters:
210
+ ruby-version: ["2.5"]
211
+ filters:
212
+ branches:
213
+ only: master
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/on_strum/healthcheck/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'on_strum-healthcheck'
7
+ spec.version = OnStrum::Healthcheck::VERSION
8
+ spec.authors = ['Vladislav Trotsenko']
9
+ spec.email = %w[admin@on-strum.org]
10
+ spec.summary = %(Simple configurable application healthcheck rack middleware)
11
+ spec.description = %(Simple configurable application healthcheck rack middleware.)
12
+ spec.homepage = 'https://github.com/on-strum/ruby-on-strum-healthcheck'
13
+ spec.license = 'MIT'
14
+
15
+ spec.required_ruby_version = '>= 2.5.0'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = %w[lib]
18
+
19
+ spec.add_runtime_dependency 'rack', '>= 2.0.1'
20
+
21
+ spec.add_development_dependency 'ffaker'
22
+ spec.add_development_dependency 'json_matchers'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rspec'
25
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/on_strum/healthcheck/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'on_strum-healthcheck'
7
+ spec.version = OnStrum::Healthcheck::VERSION
8
+ spec.authors = ['Vladislav Trotsenko']
9
+ spec.email = %w[admin@on-strum.org]
10
+ spec.summary = %(Simple configurable application healthcheck rack middleware)
11
+ spec.description = %(Simple configurable application healthcheck rack middleware.)
12
+ spec.homepage = 'https://github.com/on-strum/ruby-on-strum-healthcheck'
13
+ spec.license = 'MIT'
14
+
15
+ spec.required_ruby_version = '>= 2.5.0'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = %w[lib]
18
+
19
+ spec.add_runtime_dependency 'rack', '>= 2.0.1'
20
+
21
+ spec.add_development_dependency 'bundler-audit', '~> 0.9.1'
22
+ spec.add_development_dependency 'fasterer', '~> 0.11.0'
23
+ spec.add_development_dependency 'ffaker', '~> 2.23'
24
+ spec.add_development_dependency 'json_matchers', '~> 0.11.1'
25
+ spec.add_development_dependency 'pry-byebug', '~> 3.10', '>= 3.10.1'
26
+ spec.add_development_dependency 'rake', '~> 13.1'
27
+ spec.add_development_dependency 'reek', '~> 6.3'
28
+ spec.add_development_dependency 'rspec', '~> 3.13'
29
+ spec.add_development_dependency 'rubocop', '~> 1.62', '>= 1.62.1'
30
+ spec.add_development_dependency 'rubocop-performance', '~> 1.20', '>= 1.20.2'
31
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.27', '>= 2.27.1'
32
+ spec.add_development_dependency 'simplecov', '~> 0.22.0'
33
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+
3
+ ignore:
4
+ - EXA-MPLE-XXXX
@@ -0,0 +1,30 @@
1
+ ---
2
+
3
+ enableGlobDot: true
4
+
5
+ patterns:
6
+ - name: GithubUser
7
+ pattern: /\[@.+\]/gmx
8
+
9
+ languageSettings:
10
+ - languageId: markdown
11
+ ignoreRegExpList:
12
+ - Email
13
+ - GithubUser
14
+
15
+ words:
16
+ - bagage
17
+ - bagages
18
+ - bestwebua
19
+ - codebases
20
+ - codeclimate
21
+ - commitspell
22
+ - creds
23
+ - gemspecs
24
+ - healthcheck
25
+ - lefthook
26
+ - markdownlint
27
+ - rubocop
28
+ - simplecov
29
+ - stdlib
30
+ - yamlint
@@ -0,0 +1,31 @@
1
+ ---
2
+
3
+ enableGlobDot: true
4
+
5
+ patterns:
6
+ - name: GithubUser
7
+ pattern: /\[@.+\]/gmx
8
+ - name: MarkdownCode
9
+ pattern: /`{1,3}.+`{1,3}/gmx
10
+ - name: MarkdownCodeBlock
11
+ pattern: /^\s*```[\s\S]*?^\s*```/gmx
12
+
13
+ languageSettings:
14
+ - languageId: markdown
15
+ ignoreRegExpList:
16
+ - Email
17
+ - GithubUser
18
+ - MarkdownCode
19
+ - MarkdownCodeBlock
20
+
21
+ words:
22
+ - Serhiy
23
+ - Nazarov
24
+ - commiting
25
+ - codebases
26
+ - gemspecs
27
+ - onstrum
28
+ - healthcheck
29
+ - healthchecks
30
+ - roda
31
+ - hanami
@@ -0,0 +1,4 @@
1
+ ---
2
+
3
+ exclude_paths:
4
+ - '.circleci/**/*.rb'
@@ -0,0 +1,44 @@
1
+ ---
2
+
3
+ no_tty: true
4
+ skip_output:
5
+ - meta
6
+
7
+ commit-linters:
8
+ commands:
9
+ commitspell:
10
+ run: .circleci/scripts/commitspell.sh -c '.circleci/linter_configs/.commitspell.yml'
11
+
12
+ code-style-linters:
13
+ commands:
14
+ reek:
15
+ run: bundle exec reek
16
+ rubocop:
17
+ run: bundle exec rubocop -c '.circleci/linter_configs/.rubocop.yml'
18
+ shellcheck:
19
+ glob: '*.{sh}'
20
+ run: shellcheck --norc {all_files}
21
+ yamllint:
22
+ run: yamllint -c '.circleci/linter_configs/.yamllint.yml' .
23
+
24
+ code-performance-linters:
25
+ commands:
26
+ fasterer:
27
+ run: bundle exec fasterer
28
+
29
+ code-vulnerability-linters:
30
+ commands:
31
+ bundle-audit:
32
+ run: bundle exec bundle-audit check -c '.circleci/linter_configs/.bundler-audit.yml' --update
33
+
34
+ code-documentation-linters:
35
+ commands:
36
+ cspell:
37
+ run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}'
38
+ markdownlint:
39
+ run: markdownlint -c '.circleci/linter_configs/.markdownlint.yml' '**/*.md'
40
+
41
+ release-linters:
42
+ commands:
43
+ changeloglint:
44
+ run: .circleci/scripts/changeloglint.sh
@@ -0,0 +1,9 @@
1
+ ---
2
+
3
+ default: true
4
+
5
+ MD013:
6
+ line_length: 500
7
+
8
+ MD024:
9
+ siblings_only: true
@@ -0,0 +1,137 @@
1
+ ---
2
+
3
+ require:
4
+ - rubocop-rspec
5
+ - rubocop-performance
6
+
7
+ AllCops:
8
+ DisplayCopNames: true
9
+ DisplayStyleGuide: true
10
+ TargetRubyVersion: 2.5
11
+ SuggestExtensions: false
12
+ NewCops: enable
13
+
14
+ # Metrics ---------------------------------------------------------------------
15
+
16
+ Metrics/ClassLength:
17
+ Max: 150
18
+
19
+ Metrics/MethodLength:
20
+ Max: 15
21
+
22
+ Metrics/BlockLength:
23
+ Enabled: false
24
+
25
+ Metrics/CyclomaticComplexity:
26
+ Enabled: false
27
+
28
+ Metrics/PerceivedComplexity:
29
+ Enabled: false
30
+
31
+ # Naming ----------------------------------------------------------------------
32
+
33
+ Naming/VariableNumber:
34
+ Enabled: false
35
+
36
+ Naming/RescuedExceptionsVariableName:
37
+ Enabled: false
38
+
39
+ Naming/InclusiveLanguage:
40
+ Enabled: false
41
+
42
+ # Style -----------------------------------------------------------------------
43
+
44
+ Style/Documentation:
45
+ Enabled: false
46
+
47
+ Style/DoubleNegation:
48
+ Enabled: false
49
+
50
+ Style/EmptyCaseCondition:
51
+ Enabled: false
52
+
53
+ Style/ParallelAssignment:
54
+ Enabled: false
55
+
56
+ Style/RescueStandardError:
57
+ Enabled: false
58
+
59
+ Style/RedundantConstantBase:
60
+ Enabled: false
61
+
62
+ # Layout ----------------------------------------------------------------------
63
+
64
+ Layout/LineLength:
65
+ Max: 150
66
+
67
+ Layout/ClassStructure:
68
+ Enabled: true
69
+ Categories:
70
+ module_inclusion:
71
+ - include
72
+ - prepend
73
+ - extend
74
+ ExpectedOrder:
75
+ - module_inclusion
76
+ - constants
77
+ - public_class_methods
78
+ - initializer
79
+ - public_methods
80
+ - protected_methods
81
+ - private_methods
82
+
83
+ Layout/EmptyLineAfterGuardClause:
84
+ Enabled: false
85
+
86
+ # Lint ------------------------------------------------------------------------
87
+
88
+ Lint/NoReturnInBeginEndBlocks:
89
+ Enabled: false
90
+
91
+ # Gemspec ---------------------------------------------------------------------
92
+
93
+ Gemspec/RequireMFA:
94
+ Enabled: false
95
+
96
+ Gemspec/DevelopmentDependencies:
97
+ Enabled: false
98
+
99
+ # Performance -----------------------------------------------------------------
100
+
101
+ Performance/MethodObjectAsBlock:
102
+ Enabled: false
103
+
104
+ # RSpec -----------------------------------------------------------------------
105
+
106
+ RSpec/ExampleLength:
107
+ Enabled: false
108
+
109
+ RSpec/NestedGroups:
110
+ Enabled: false
111
+
112
+ RSpec/MultipleExpectations:
113
+ Enabled: false
114
+
115
+ RSpec/MessageChain:
116
+ Enabled: false
117
+
118
+ RSpec/ContextWording:
119
+ Enabled: false
120
+
121
+ RSpec/AnyInstance:
122
+ Enabled: false
123
+
124
+ RSpec/MessageSpies:
125
+ Enabled: false
126
+
127
+ RSpec/MultipleDescribes:
128
+ Enabled: false
129
+
130
+ RSpec/MultipleMemoizedHelpers:
131
+ Enabled: false
132
+
133
+ RSpec/StubbedMock:
134
+ Enabled: false
135
+
136
+ RSpec/VerifiedDoubleReference:
137
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ ---
2
+
3
+ extends: default
4
+
5
+ rules:
6
+ line-length:
7
+ max: 200
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ changelog=$(if [ "$1" = "" ]; then echo "CHANGELOG.md"; else echo "$1"; fi)
5
+
6
+ get_current_gem_version() {
7
+ ruby -r rubygems -e "puts Gem::Specification::load('$(ls -- *.gemspec)').version"
8
+ }
9
+
10
+ latest_changelog_tag() {
11
+ grep -Po "(?<=\#\# \[)[0-9]+\.[0-9]+\.[0-9]+?(?=\])" "$changelog" | head -n 1
12
+ }
13
+
14
+ current_gem_version="$(get_current_gem_version)"
15
+
16
+ if [ "$current_gem_version" = "$(latest_changelog_tag)" ]
17
+ then
18
+ echo "SUCCESS: Current gem version ($current_gem_version) has been found on the top of project changelog."
19
+ else
20
+ echo "FAILURE: Following to \"Keep a Changelog\" convention current gem version ($current_gem_version) must be mentioned on the top of project changelog."
21
+ exit 1
22
+ fi
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ configuration=$(if [ "$2" = "" ]; then echo "$2"; else echo " $1 $2"; fi)
5
+ latest_commit=$(git rev-parse HEAD)
6
+
7
+ spellcheck_info() {
8
+ echo "Checking the spelling of the latest commit ($latest_commit) message..."
9
+ }
10
+
11
+ compose_cspell_command() {
12
+ echo "cspell-cli lint stdin$configuration"
13
+ }
14
+
15
+ cspell="$(compose_cspell_command)"
16
+
17
+ spellcheck_latest_commit() {
18
+ git log -1 --pretty=%B | $cspell
19
+ }
20
+
21
+ spellcheck_info
22
+ spellcheck_latest_commit
@@ -0,0 +1,69 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ GH_CLI_RELEASES_URL="https://github.com/cli/cli/releases"
5
+ FILE_NAME="gh"
6
+ BUILD_ARCHITECTURE="linux_amd64.deb"
7
+ DELIMETER="_"
8
+ PACKAGE_FILE="$FILE_NAME$DELIMETER$BUILD_ARCHITECTURE"
9
+
10
+ gh_cli_latest_release() {
11
+ curl -sL -o /dev/null -w '%{url_effective}' "$GH_CLI_RELEASES_URL/latest" | rev | cut -f 1 -d '/'| rev
12
+ }
13
+
14
+ download_gh_cli() {
15
+ test -z "$VERSION" && VERSION="$(gh_cli_latest_release)"
16
+ test -z "$VERSION" && {
17
+ echo "Unable to get GitHub CLI release." >&2
18
+ exit 1
19
+ }
20
+ curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER$(printf '%s' "$VERSION" | cut -c 2-100)$DELIMETER$BUILD_ARCHITECTURE"
21
+ }
22
+
23
+ install_gh_cli() {
24
+ sudo dpkg -i "$PACKAGE_FILE"
25
+ rm "$PACKAGE_FILE"
26
+ }
27
+
28
+ get_release_candidate_version() {
29
+ ruby -r rubygems -e "puts Gem::Specification::load('$(ls -- *.gemspec)').version"
30
+ }
31
+
32
+ release_candidate_tag="v$(get_release_candidate_version)"
33
+
34
+ is_an_existing_github_release() {
35
+ git fetch origin "refs/tags/$release_candidate_tag" >/dev/null 2>&1
36
+ }
37
+
38
+ release_to_rubygems() {
39
+ echo "Setting RubyGems publisher credentials..."
40
+ ./.circleci/scripts/set_publisher_credentials.sh
41
+ echo "Preparation for release..."
42
+ git config --global user.email "${PUBLISHER_EMAIL}"
43
+ git config --global user.name "${PUBLISHER_NAME}"
44
+ git stash
45
+ gem install yard gem-ctags
46
+ bundle install
47
+ echo "Publishing new gem release to RubyGems..."
48
+ rake release
49
+ }
50
+
51
+ release_to_github() {
52
+ echo "Downloading and installing latest gh cli..."
53
+ download_gh_cli
54
+ install_gh_cli
55
+ echo "Publishing new release notes to GitHub..."
56
+ gh release create "$release_candidate_tag" --generate-notes
57
+ }
58
+
59
+ update_develop_branch() {
60
+ echo "Updating develop branch with new release tag..."
61
+ git checkout develop
62
+ git merge "$release_candidate_tag" --ff --no-edit
63
+ git push origin develop
64
+ }
65
+
66
+ if is_an_existing_github_release
67
+ then echo "Tag $release_candidate_tag already exists on GitHub. Skipping releasing flow..."
68
+ else release_to_rubygems; release_to_github; update_develop_branch
69
+ fi
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ set -e
3
+ set +x
4
+ mkdir -p ~/.gem
5
+
6
+ cat << EOF > ~/.gem/credentials
7
+ ---
8
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
9
+ EOF
10
+
11
+ chmod 0600 ~/.gem/credentials
12
+ set -x