stream-chat-ruby 2.17.1 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c710242473edb2c9312b5b57dc676a1558b2394a0173cf589c307286b8645b7
4
- data.tar.gz: 3ecdd4d99f269992643b16457caf3d0546e0129f0a878558df2c2c3e563917df
3
+ metadata.gz: 36870782d8439c010ce69c4593b2a9007b25ea0c18f748ea8bc809507378b2cd
4
+ data.tar.gz: f5eeb52979560fa3be08059c71517dd5637ef317f78f9cf6ff27f2fabe8e3d61
5
5
  SHA512:
6
- metadata.gz: fa9e6f051611eda2fbc190e8529853ca1fb897829f2dac0012599a8eda8417754ce2ce9dfa961fdc512d82a6e3251c963a4750d2eed480e9bd01c25b0b667b03
7
- data.tar.gz: 5c6e8b07bb66e283e4e1ea6750427caa77c766af655c32380d6ae2439a85d82a9f582aa5b8b7116e11667ebc722c1dcafc024c552a5d7d704fd13a12e63d8a60
6
+ metadata.gz: cdffeaa2e783243ca32b098034b27c5175993d480dd34d78b7e6b2538e2c788fef8bbcf4c32357a2ab48e14edfcee056c4b3018a0f2cc4fb1e2a09a4b5c22fb3
7
+ data.tar.gz: b2be01f9571c5ff952660fd046b35dd3fabe8920e3d3d58e50087253c74a57351ccee9b7fe5e0ccaa8fd154b64a20cd1046e6e4fd1662d1abbd1dc03ea1c5578
data/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.20.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.19.0...v2.20.0) (2022-02-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * add helper for invitation acceptance and rejection ([#78](https://github.com/GetStream/stream-chat-ruby/issues/78)) ([c950694](https://github.com/GetStream/stream-chat-ruby/commit/c950694a0ac2b0906d7bedb4ebc9a1af00eea606))
11
+
12
+ ## [2.19.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.18.0...v2.19.0) (2022-02-02)
13
+
14
+
15
+ ### Features
16
+
17
+ * ability to provide custom http client ([#75](https://github.com/GetStream/stream-chat-ruby/issues/75)) ([bfff20d](https://github.com/GetStream/stream-chat-ruby/commit/bfff20d06232c49a1a8d0eee255a718bfffbb351))
18
+ * add connection pooling and idle timeout ([#74](https://github.com/GetStream/stream-chat-ruby/issues/74)) ([7891005](https://github.com/GetStream/stream-chat-ruby/commit/78910053b3a15b1efa3183a71299068e63b128e3))
19
+ * env var handling enhancement ([#76](https://github.com/GetStream/stream-chat-ruby/issues/76)) ([0cdc38a](https://github.com/GetStream/stream-chat-ruby/commit/0cdc38abd671bfaa8cefa7f403b9e2ac8b642272))
20
+ > 🚨 Note: if you used `STREAM_CHAT_URL` env var, you'll need to provide it manually in the `**options` as `base_url`. See the initializer of `Client` class for more information.
21
+
22
+ ## [2.18.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.17.2...v2.18.0) (2022-01-26)
23
+
24
+
25
+ ### Features
26
+
27
+ * expose rate limits ([#72](https://github.com/GetStream/stream-chat-ruby/issues/72)) ([3f1ad5c](https://github.com/GetStream/stream-chat-ruby/commit/3f1ad5c8f43263424e934055d0ac283cdcce9376))
28
+ * full feature parity ([#71](https://github.com/GetStream/stream-chat-ruby/issues/71)) ([a25a1b6](https://github.com/GetStream/stream-chat-ruby/commit/a25a1b66f9eadd77d09b99d5c3cfba27bba52f17))
29
+
30
+ ### [2.17.2](https://github.com/GetStream/stream-chat-ruby/compare/v2.17.1...v2.17.2) (2022-01-17)
31
+
32
+ ### Features
33
+ * added some new metadata to the gemspec ([#69](https://github.com/GetStream/stream-chat-ruby/issues/69)) ([3e747bc](https://github.com/GetStream/stream-chat-ruby/commit/3e747bcd6aa338b08e136febfb0cf06f29d366b5))
34
+
5
35
  ### [2.17.1](https://github.com/GetStream/stream-chat-ruby/compare/v2.17.0...v2.17.1) (2022-01-17)
6
36
 
7
37
 
data/README.md CHANGED
@@ -213,7 +213,7 @@ See [an example rails application using the Ruby SDK](https://github.com/GetStre
213
213
  First, make sure you can run the test suite. Tests are run via rspec
214
214
 
215
215
  ```bash
216
- STREAM_CHAT_API_KEY=my_api_key STREAM_CHAT_API_SECRET=my_api_secret bundle exec rake spec
216
+ STREAM_KEY=my_api_key STREAM_SECRET=my_api_secret bundle exec rake spec
217
217
  ```
218
218
 
219
219
  This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.
@@ -229,3 +229,10 @@ The job creates a pull request with the changelog. Check if it looks good.
229
229
  - Merge the pull request.
230
230
 
231
231
  Once the PR is merged, it automatically kicks off another job which will upload the Gem to RubyGems.org and creates a GitHub release.
232
+
233
+ ## We are hiring!
234
+
235
+ We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
236
+ Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
237
+
238
+ Check out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).
@@ -13,6 +13,7 @@ module StreamChat
13
13
  def initialize(client, channel_type, channel_id = nil, custom_data = nil)
14
14
  @channel_type = channel_type
15
15
  @id = channel_id
16
+ @cid = "#{@channel_type}:#{@id}"
16
17
  @client = client
17
18
  @custom_data = custom_data
18
19
  @custom_data = {} if @custom_data.nil?
@@ -24,6 +25,10 @@ module StreamChat
24
25
  "channels/#{@channel_type}/#{@id}"
25
26
  end
26
27
 
28
+ def get_messages(message_ids)
29
+ @client.get("#{url}/messages", params: { 'ids' => message_ids.join(',') })
30
+ end
31
+
27
32
  def send_message(message, user_id)
28
33
  payload = { message: add_user_id(message, user_id) }
29
34
  @client.post("#{url}/message", data: payload)
@@ -79,8 +84,8 @@ module StreamChat
79
84
  @client.get('members', params: { payload: params.to_json })
80
85
  end
81
86
 
82
- def update(channel_data, update_message = nil)
83
- payload = { data: channel_data, message: update_message }
87
+ def update(channel_data, update_message = nil, **options)
88
+ payload = { data: channel_data, message: update_message }.merge(options)
84
89
  @client.post(url, data: payload)
85
90
  end
86
91
 
@@ -99,29 +104,50 @@ module StreamChat
99
104
  @client.post("#{url}/truncate", data: options)
100
105
  end
101
106
 
107
+ def mute(user_id, expiration = nil)
108
+ data = { user_id: user_id, channel_cid: @cid }
109
+ data['expiration'] = expiration if expiration
110
+ @client.post('moderation/mute/channel', data: data)
111
+ end
112
+
113
+ def unmute(user_id)
114
+ @client.post('moderation/unmute/channel', data: { 'user_id' => user_id, 'channel_cid' => @cid })
115
+ end
116
+
102
117
  def add_members(user_ids, **options)
103
118
  payload = options.merge({ add_members: user_ids })
104
- @client.post(url, data: payload)
119
+ update(nil, nil, **payload)
120
+ end
121
+
122
+ def invite_members(user_ids, **options)
123
+ payload = options.merge({ invites: user_ids })
124
+ update(nil, nil, **payload)
125
+ end
126
+
127
+ def accept_invite(user_id, **options)
128
+ payload = options.merge({ user_id: user_id, accept_invite: true })
129
+ update(nil, nil, **payload)
105
130
  end
106
131
 
107
- def invite_members(user_ids)
108
- @client.post(url, data: { invites: user_ids })
132
+ def reject_invite(user_id, **options)
133
+ payload = options.merge({ user_id: user_id, reject_invite: true })
134
+ update(nil, nil, **payload)
109
135
  end
110
136
 
111
137
  def add_moderators(user_ids)
112
- @client.post(url, data: { add_moderators: user_ids })
138
+ update(nil, nil, add_moderators: user_ids)
113
139
  end
114
140
 
115
141
  def remove_members(user_ids)
116
- @client.post(url, data: { remove_members: user_ids })
142
+ update(nil, nil, remove_members: user_ids)
117
143
  end
118
144
 
119
145
  def assign_roles(members, message = nil)
120
- @client.post(url, data: { assign_roles: members, message: message })
146
+ update(nil, message, assign_roles: members)
121
147
  end
122
148
 
123
149
  def demote_moderators(user_ids)
124
- @client.post(url, data: { demote_moderators: user_ids })
150
+ update(nil, nil, demote_moderators: user_ids)
125
151
  end
126
152
 
127
153
  def mark_read(user_id, **options)
@@ -4,10 +4,12 @@
4
4
  require 'open-uri'
5
5
  require 'faraday'
6
6
  require 'faraday/multipart'
7
+ require 'faraday/net_http_persistent'
7
8
  require 'jwt'
8
9
  require 'time'
9
10
  require 'stream-chat/channel'
10
11
  require 'stream-chat/errors'
12
+ require 'stream-chat/stream_response'
11
13
  require 'stream-chat/version'
12
14
  require 'stream-chat/util'
13
15
 
@@ -17,7 +19,8 @@ module StreamChat
17
19
  HARD_DELETE = 'hard'
18
20
 
19
21
  class Client
20
- BASE_URL = 'https://chat.stream-io-api.com'
22
+ DEFAULT_BASE_URL = 'https://chat.stream-io-api.com'
23
+ DEFAULT_TIMEOUT = 6.0
21
24
 
22
25
  attr_reader :api_key
23
26
  attr_reader :api_secret
@@ -28,27 +31,50 @@ module StreamChat
28
31
  #
29
32
  # @param [string] api_key your application api_key
30
33
  # @param [string] api_secret your application secret
31
- # @param [string]
32
- # @param [hash] options extra options
34
+ # @param [float] timeout the timeout for the http requests
35
+ # @param [hash] options extra options such as base_url
33
36
  #
34
37
  # @example initialized the client with a timeout setting
35
38
  # StreamChat::Client.new('my_key', 'my_secret', 3.0)
36
39
  #
37
- def initialize(api_key = '', api_secret = '', timeout = 6.0, **options)
40
+ def initialize(api_key, api_secret, timeout = nil, **options)
41
+ raise ArgumentError, 'api_key and api_secret are required' if api_key.to_s.empty? || api_secret.to_s.empty?
42
+
38
43
  @api_key = api_key
39
44
  @api_secret = api_secret
40
- @timeout = timeout
45
+ @timeout = timeout || DEFAULT_TIMEOUT
41
46
  @options = options
42
47
  @auth_token = JWT.encode({ server: true }, @api_secret, 'HS256')
43
- @base_url = options[:base_url] || BASE_URL
48
+ @base_url = options[:base_url] || DEFAULT_BASE_URL
44
49
  @conn = Faraday.new(url: @base_url) do |faraday|
45
50
  faraday.options[:open_timeout] = @timeout
46
51
  faraday.options[:timeout] = @timeout
47
52
  faraday.request :multipart
48
- faraday.adapter :net_http
53
+ faraday.adapter :net_http_persistent, pool_size: 5 do |http|
54
+ # AWS load balancer idle timeout is 60 secs, so let's make it 59
55
+ http.idle_timeout = 59
56
+ end
49
57
  end
50
58
  end
51
59
 
60
+ # initializes a Stream Chat API Client from STREAM_KEY and STREAM_SECRET
61
+ # environmental variables. STREAM_CHAT_TIMEOUT and STREAM_CHAT_URL
62
+ # variables are optional.
63
+ # @param [hash] options extra options
64
+ def self.from_env(**options)
65
+ Client.new(ENV['STREAM_KEY'],
66
+ ENV['STREAM_SECRET'],
67
+ ENV['STREAM_CHAT_TIMEOUT'],
68
+ **{ base_url: ENV['STREAM_CHAT_URL'] }.merge(options))
69
+ end
70
+
71
+ # Sets the underlying Faraday http client.
72
+ #
73
+ # @param [client] an instance of Faraday::Connection
74
+ def set_http_client(client)
75
+ @conn = client
76
+ end
77
+
52
78
  def create_token(user_id, exp = nil, iat = nil)
53
79
  payload = { user_id: user_id }
54
80
  payload['exp'] = exp unless exp.nil?
@@ -221,6 +247,14 @@ module StreamChat
221
247
  delete("messages/#{message_id}")
222
248
  end
223
249
 
250
+ def query_banned_users(filter_conditions, sort: nil, **options)
251
+ params = options.merge({
252
+ filter_conditions: filter_conditions,
253
+ sort: get_sort_fields(sort)
254
+ })
255
+ get('query_banned_users', params: { payload: params.to_json })
256
+ end
257
+
224
258
  def query_users(filter_conditions, sort: nil, **options)
225
259
  params = options.merge({
226
260
  filter_conditions: filter_conditions,
@@ -303,6 +337,22 @@ module StreamChat
303
337
  signature == x_signature
304
338
  end
305
339
 
340
+ def send_user_event(user_id, event)
341
+ post("users/#{user_id}/event", data: event)
342
+ end
343
+
344
+ def translate_message(message_id, language)
345
+ post("messages/#{message_id}/translate", data: { language: language })
346
+ end
347
+
348
+ def run_message_action(message_id, data)
349
+ post("messages/#{message_id}/action", data: data)
350
+ end
351
+
352
+ def create_guest(user)
353
+ post('guests', data: user)
354
+ end
355
+
306
356
  def list_blocklists
307
357
  get('blocklists')
308
358
  end
@@ -405,6 +455,10 @@ module StreamChat
405
455
  parse_response(response)
406
456
  end
407
457
 
458
+ def check_push(push_data)
459
+ post('check_push', data: push_data)
460
+ end
461
+
408
462
  def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
409
463
  post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
410
464
  end
@@ -486,17 +540,16 @@ module StreamChat
486
540
  end
487
541
  raise StreamAPIException, response if response.status >= 399
488
542
 
489
- parsed_result
543
+ StreamResponse.new(parsed_result, response)
490
544
  end
491
545
 
492
546
  def make_http_request(method, relative_url, params: nil, data: nil)
493
547
  headers = get_default_headers
494
548
  headers['Authorization'] = @auth_token
495
549
  headers['stream-auth-type'] = 'jwt'
496
- url = [@base_url, relative_url].join('/')
497
550
  params = {} if params.nil?
498
551
  params = (get_default_params.merge(params).sort_by { |k, _v| k.to_s }).to_h
499
- url = "#{url}?#{URI.encode_www_form(params)}"
552
+ url = "#{relative_url}?#{URI.encode_www_form(params)}"
500
553
 
501
554
  body = data.to_json if %w[patch post put].include? method.to_s
502
555
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/stream_rate_limits.rb
4
+
5
+ module StreamChat
6
+ class StreamRateLimits
7
+ attr_reader :limit
8
+ attr_reader :remaining
9
+ attr_reader :reset
10
+
11
+ def initialize(limit, remaining, reset)
12
+ @limit = limit.to_i
13
+ @remaining = remaining.to_i
14
+ @reset = Time.at(reset.to_i)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/stream_response.rb
4
+ require 'stream-chat/stream_rate_limits'
5
+
6
+ module StreamChat
7
+ class StreamResponse < Hash
8
+ attr_reader :rate_limit
9
+ attr_reader :status_code
10
+ attr_reader :headers
11
+
12
+ def initialize(hash, response)
13
+ super(nil)
14
+ merge!(hash)
15
+
16
+ if response.headers.key?('X-Ratelimit-Limit')
17
+ @rate_limit = StreamRateLimits.new(
18
+ response.headers['X-Ratelimit-Limit'],
19
+ response.headers['X-Ratelimit-Remaining'],
20
+ response.headers['X-Ratelimit-Reset']
21
+ )
22
+ end
23
+
24
+ @status_code = response.status
25
+ @headers = response.headers
26
+ end
27
+ end
28
+ end
@@ -3,5 +3,5 @@
3
3
  # lib/version.rb
4
4
 
5
5
  module StreamChat
6
- VERSION = '2.17.1'
6
+ VERSION = '2.20.0'
7
7
  end
data/stream-chat.gemspec CHANGED
@@ -12,17 +12,26 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = 'The low level client for serverside calls for Stream Chat.'
13
13
  gem.email = 'support@getstream.io'
14
14
  gem.homepage = 'http://github.com/GetStream/stream-chat-ruby'
15
- gem.authors = ['Mircea Cosbuc']
15
+ gem.authors = ['getstream.io']
16
16
  gem.files = Dir.chdir(File.expand_path(__dir__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|\.github|scripts)/}) }
18
18
  end
19
19
  gem.required_ruby_version = '>=2.5.0'
20
+ gem.metadata = {
21
+ 'rubygems_mfa_required' => 'false',
22
+ 'homepage_uri' => 'https://getstream.io/chat/docs/',
23
+ 'bug_tracker_uri' => 'https://github.com/GetStream/stream-chat-ruby/issues',
24
+ 'documentation_uri' => 'https://getstream.io/chat/docs/ruby/?language=ruby',
25
+ 'changelog_uri' => 'https://github.com/GetStream/stream-chat-ruby/blob/master/CHANGELOG.md',
26
+ 'source_code_uri' => 'https://github.com/GetStream/stream-chat-ruby'
27
+ }
20
28
 
21
29
  gem.add_dependency 'faraday'
22
30
  gem.add_dependency 'faraday-multipart'
31
+ gem.add_dependency 'faraday-net_http_persistent'
23
32
  gem.add_dependency 'jwt'
33
+ gem.add_dependency 'net-http-persistent'
24
34
  gem.add_development_dependency 'rake'
25
35
  gem.add_development_dependency 'rspec'
26
36
  gem.add_development_dependency 'simplecov'
27
- gem.metadata['rubygems_mfa_required'] = 'false'
28
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.17.1
4
+ version: 2.20.0
5
5
  platform: ruby
6
6
  authors:
7
- - Mircea Cosbuc
7
+ - getstream.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-net_http_persistent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: jwt
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,20 @@ dependencies:
52
66
  - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: net-http-persistent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rake
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,10 +128,6 @@ executables: []
100
128
  extensions: []
101
129
  extra_rdoc_files: []
102
130
  files:
103
- - ".github/CODEOWNERS"
104
- - ".github/workflows/ci.yml"
105
- - ".github/workflows/initiate_release.yml"
106
- - ".github/workflows/release.yml"
107
131
  - ".gitignore"
108
132
  - ".rubocop.yml"
109
133
  - ".versionrc.js"
@@ -117,14 +141,20 @@ files:
117
141
  - lib/stream-chat/channel.rb
118
142
  - lib/stream-chat/client.rb
119
143
  - lib/stream-chat/errors.rb
144
+ - lib/stream-chat/stream_rate_limits.rb
145
+ - lib/stream-chat/stream_response.rb
120
146
  - lib/stream-chat/util.rb
121
147
  - lib/stream-chat/version.rb
122
- - scripts/get_changelog_diff.js
123
148
  - stream-chat.gemspec
124
149
  homepage: http://github.com/GetStream/stream-chat-ruby
125
150
  licenses: []
126
151
  metadata:
127
152
  rubygems_mfa_required: 'false'
153
+ homepage_uri: https://getstream.io/chat/docs/
154
+ bug_tracker_uri: https://github.com/GetStream/stream-chat-ruby/issues
155
+ documentation_uri: https://getstream.io/chat/docs/ruby/?language=ruby
156
+ changelog_uri: https://github.com/GetStream/stream-chat-ruby/blob/master/CHANGELOG.md
157
+ source_code_uri: https://github.com/GetStream/stream-chat-ruby
128
158
  post_install_message:
129
159
  rdoc_options: []
130
160
  require_paths:
@@ -140,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
170
  - !ruby/object:Gem::Version
141
171
  version: '0'
142
172
  requirements: []
143
- rubygems_version: 3.0.3
173
+ rubygems_version: 3.1.2
144
174
  signing_key:
145
175
  specification_version: 4
146
176
  summary: The low level client for serverside calls for Stream Chat.
data/.github/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @ffenix113
@@ -1,33 +0,0 @@
1
- name: test
2
-
3
- on: [pull_request]
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
- strategy:
9
- max-parallel: 1
10
- matrix:
11
- ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
12
- name: 💎 Ruby ${{ matrix.ruby }}
13
- steps:
14
- - uses: actions/checkout@v2
15
- with:
16
- fetch-depth: 0 # gives the commit linter access to previous commits
17
-
18
- - name: Commit message linter
19
- if: ${{ matrix.ruby == '2.5' }}
20
- uses: wagoid/commitlint-github-action@v4
21
-
22
- - uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby }}
25
- bundler-cache: true
26
-
27
- - run: bundle exec rake rubocop
28
-
29
- - run: bundle exec rake test
30
- env:
31
- STREAM_CHAT_API_KEY: ${{ secrets.STREAM_CHAT_API_KEY }}
32
- STREAM_CHAT_API_SECRET: ${{ secrets.STREAM_CHAT_API_SECRET }}
33
- STREAM_CHAT_API_HOST: ${{ secrets.STREAM_CHAT_API_HOST }}
@@ -1,47 +0,0 @@
1
- name: Create release PR
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version:
7
- description: "The new version number with 'v' prefix. Example: v1.40.1"
8
- required: true
9
-
10
- jobs:
11
- init_release:
12
- name: 🚀 Create release PR
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v2
16
- with:
17
- fetch-depth: 0 # gives the changelog generator access to all previous commits
18
-
19
- - name: Update CHANGELOG.md, version.rb and push release branch
20
- env:
21
- VERSION: ${{ github.event.inputs.version }}
22
- run: |
23
- npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix=v
24
- git config --global user.name 'github-actions'
25
- git config --global user.email 'release@getstream.io'
26
- git checkout -q -b "release-$VERSION"
27
- git commit -am "chore(release): $VERSION"
28
- git push -q -u origin "release-$VERSION"
29
-
30
- - name: Get changelog diff
31
- uses: actions/github-script@v5
32
- with:
33
- script: |
34
- const get_change_log_diff = require('./scripts/get_changelog_diff.js')
35
- core.exportVariable('CHANGELOG', get_change_log_diff())
36
-
37
- - name: Open pull request
38
- env:
39
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40
- run: |
41
- gh pr create \
42
- -t "Release ${{ github.event.inputs.version }}" \
43
- -b "# :rocket: ${{ github.event.inputs.version }}
44
- Make sure to use squash & merge when merging!
45
- Once this is merged, another job will kick off automatically and publish the package.
46
- # :memo: Changelog
47
- ${{ env.CHANGELOG }}"
@@ -1,40 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- pull_request:
5
- types: [closed]
6
- branches:
7
- - master
8
-
9
- jobs:
10
- Release:
11
- name: 🚀 Release
12
- if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v2
16
- with:
17
- fetch-depth: 0
18
-
19
- - uses: actions/github-script@v5
20
- with:
21
- script: |
22
- const get_change_log_diff = require('./scripts/get_changelog_diff.js')
23
- core.exportVariable('CHANGELOG', get_change_log_diff())
24
-
25
- // Getting the release version from the PR source branch
26
- // Source branch looks like this: release-1.0.0
27
- const version = context.payload.pull_request.head.ref.split('-')[1]
28
- core.exportVariable('VERSION', version)
29
-
30
- - name: Publish gem
31
- uses: dawidd6/action-publish-gem@v1
32
- with:
33
- api_key: ${{secrets.RUBYGEMS_API_KEY}}
34
-
35
- - name: Create release on GitHub
36
- uses: ncipollo/release-action@v1
37
- with:
38
- body: ${{ env.CHANGELOG }}
39
- tag: ${{ env.VERSION }}
40
- token: ${{ secrets.GITHUB_TOKEN }}
@@ -1,26 +0,0 @@
1
- /*
2
- Here we're trying to parse the latest changes from CHANGELOG.md file.
3
- The changelog looks like this:
4
-
5
- ## 0.0.3
6
- - Something #3
7
- ## 0.0.2
8
- - Something #2
9
- ## 0.0.1
10
- - Something #1
11
-
12
- In this case we're trying to extract "- Something #3" since that's the latest change.
13
- */
14
- module.exports = () => {
15
- const fs = require('fs')
16
-
17
- changelog = fs.readFileSync('CHANGELOG.md', 'utf8')
18
- releases = changelog.match(/## [?[0-9](.+)/g)
19
-
20
- current_release = changelog.indexOf(releases[0])
21
- previous_release = changelog.indexOf(releases[1])
22
-
23
- latest_changes = changelog.substr(current_release, previous_release - current_release)
24
-
25
- return latest_changes
26
- }