fastlane-plugin-rustore 0.1.1 → 0.3.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: 9529d690ce6b1a41ad75c570801b2b9f596021d7495ba2142f82b223a8305070
4
- data.tar.gz: fceffdb0c7f2f4d7dbcd4e67f2d1c5d0db4aef89977209ee3c4255afdf496b4d
3
+ metadata.gz: fd8b75fbb201a3400db901e3d014e10697c12308b5c250fbc669d867181c1311
4
+ data.tar.gz: 2f5bbe7b9a5f5ab02531c81d47cbf7051eddbae7a338d747bc7befd204a0139a
5
5
  SHA512:
6
- metadata.gz: 7fdb15a40ad70fc10f4f70e89afe1e9f4839b2a2ddd4b96370ceb774dbd0f876e822ac676b56b97575073e0f670401bc15270c97bd13145c18fb0b7adc01766f
7
- data.tar.gz: 6d20f557358bf2835ab082a24be4adf9b0e60f022ad9294cdf8bd7941bd296b5787b17ef200436aba0db0432e76634e998eb2d170363fe9698c0293131552097
6
+ metadata.gz: 1e2a1c5340c7c3a46aec090debc74b102123edc74cdb3b3222953cf82c29fa63e2dccf3f39571ec6d9186ad98dc220e34d2b9b0660eb2a6d8a8dc40b7788edf0
7
+ data.tar.gz: 10c5a5490ea0affce79e930e96c9e2de43fa5112c2768fe608a05140ee59054e3d584bba9b89a8f52ac3630647d33905c12fd1717bfea6ef21c8cdb6214d3ae5
data/README.md CHANGED
@@ -1,55 +1,40 @@
1
- # fastlane-plugin-rustore
2
- Fastlane плагин для заливки приложений в Rustore
1
+ # Fastlane Rustore plugin
3
2
 
4
- # Rustore plugin
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-rustore) [![stability-wip](https://img.shields.io/badge/stability-wip-lightgrey.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#work-in-progress)
5
4
 
6
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-rustore)
7
5
 
8
- ## Getting Started
6
+ ## Дисклеймер
9
7
 
10
- This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-rustore`, add it to your project by running:
8
+ Пока что реализован базовый функционал с заливкой апк. Скриншоты, описание и прочие материалы наследуются от предыдущего релиза. Обработки ошибок нет. Если у вас уже есть черновик релиза, то скорей всего ничего не заработает. Черновик, созданный через апи, в админке отображаться не будет. Если случилась ошибка где-то на этапе заливки, то останется черновик, который будет мешать следующему запуску скрипта, удалить его лучше с помощью [питонскрипта](https://github.com/stfbee/python-rustore-api), а экшен удаления тут будет чуть позже.
11
9
 
12
- ```bash
13
- fastlane add_plugin rustore
14
- ```
15
-
16
- ## About rustore
17
-
18
- Rustore fastlane integration
19
-
20
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
10
+ Также есть признаки того, что заливать апк из вне РФ больше нельзя (смотри [#2](https://github.com/stfbee/fastlane-plugin-rustore/issues/2)), так что выбирайте раннер, где будет запускаться скрипт.
21
11
 
22
- ## Example
12
+ ## Поехали
23
13
 
24
- Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
25
-
26
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
27
-
28
- ## Run tests for this plugin
29
-
30
- To run both the tests, and code style validation, run
31
-
32
- ```
33
- rake
14
+ Для начала добавь плагин в ваш fastlane проект:
15
+ ```bash
16
+ fastlane add_plugin rustore
34
17
  ```
35
-
36
- To automatically fix many of the styling issues, use
18
+ После чего в каком-нибудь лейне дергай экшен плагина:
37
19
  ```
38
- rubocop -a
20
+ rustore_publish(
21
+ gms_apk: "../../app-release.apk",
22
+ hms_apk: "../../app-release-hms.apk",
23
+ package_name: "com.example.example",
24
+ publish_type: "MANUAL"
25
+ key_id: "123123",
26
+ private_key: "MIIE....."
27
+ )
39
28
  ```
40
29
 
41
- ## Issues and Feedback
42
-
43
- For any other issues and feedback about this plugin, please submit it to this repository.
44
-
45
- ## Troubleshooting
46
-
47
- If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
48
-
49
- ## Using _fastlane_ Plugins
50
-
51
- For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
52
-
53
- ## About _fastlane_
54
-
55
- _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
30
+ * `gms_apk` - путь до .apk, который лучше скачать с гугл плея, у фастлейна даже есть для этого [инструмент](https://docs.fastlane.tools/actions/download_from_play_store/)
31
+ * `hms_apk` - путь до .apk с Huawei-сервисами (опционально). У Рустора пока все плохо с документацией об этом, но залить его можно, что получится - пока хз.
32
+ * `package_name` - название пакета
33
+ * `publish_type` - тип публикации (MANUAL - ручная, DELAYED - отложенная, INSTANTLY - автоматическая после модерации). По умолчанию - INSTANTLY.
34
+ * `key_id` и `private_key` надо взять в админке рустора, доступ к ним имеет только оунер.
35
+
36
+ ## Ссылочки
37
+ * [_fastlane_](https://github.com/fastlane/fastlane)
38
+ * [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/)
39
+ * [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/)
40
+ * [Rustore API](https://help.rustore.ru/rustore/for_developers/work_with_RuStore_API)
@@ -13,19 +13,17 @@ module Fastlane
13
13
  end
14
14
 
15
15
  def self.run(params)
16
- version_name = params[:version_name]
17
16
  package_name = params[:package_name]
18
- company_id = params[:company_id]
17
+ key_id = params[:key_id]
19
18
  private_key = params[:private_key]
19
+ publish_type = params[:publish_type]
20
20
  gms_apk = params[:gms_apk]
21
21
  hms_apk = params[:hms_apk]
22
22
 
23
23
  # Получение токена
24
- token = Helper::RustoreHelper.get_token(company_id: company_id, private_key: private_key)
25
- # Удаление черновика
26
- # Helper::RustoreHelper.delete_draft(token, draft_id, package_name)
24
+ token = Helper::RustoreHelper.get_token(key_id: key_id, private_key: private_key)
27
25
  # Создание черновика
28
- draft_id = Helper::RustoreHelper.create_draft(token, package_name, version_name)
26
+ draft_id = Helper::RustoreHelper.create_draft(token, package_name, publish_type)
29
27
  # Загрузка апк
30
28
  Helper::RustoreHelper.upload_apk(token, draft_id, false, gms_apk, package_name)
31
29
  # Если путь до хмс передали, то и его заливаем
@@ -39,23 +37,22 @@ module Fastlane
39
37
 
40
38
  def self.available_options
41
39
  [
42
- FastlaneCore::ConfigItem.new(key: :version_name,
43
- env_name: "RUSTORE_VERSION_NAME",
44
- description: "имя версии приложения, например `1.0.0 (102)`",
45
- optional: false,
46
- type: String),
47
40
  FastlaneCore::ConfigItem.new(key: :package_name,
48
41
  env_name: "RUSTORE_PACKAGE_NAME",
49
42
  description: "пакет приложения, например `com.example.example`",
50
43
  optional: false),
51
- FastlaneCore::ConfigItem.new(key: :company_id,
52
- env_name: "RUSTORE_COMPANY_ID",
53
- description: "айдишник компании в русторе",
44
+ FastlaneCore::ConfigItem.new(key: :key_id,
45
+ env_name: "RUSTORE_KEY_ID",
46
+ description: "идентификатор приватного ключа в русторе",
54
47
  optional: false),
55
48
  FastlaneCore::ConfigItem.new(key: :private_key,
56
49
  env_name: "RUSTORE_PRIVATE_KEY",
57
50
  description: "приватный ключ в русторе",
58
51
  optional: false),
52
+ FastlaneCore::ConfigItem.new(key: :publish_type,
53
+ env_name: "RUSTORE_PUBLISH_TYPE",
54
+ description: "Тип публикации (MANUAL, DELAYED, INSTANTLY). По умолчанию - INSTANTLY",
55
+ optional: true),
59
56
  FastlaneCore::ConfigItem.new(key: :gms_apk,
60
57
  env_name: "RUSTORE_GMS_APK",
61
58
  description: "путь до апк с гуглсервисами",
@@ -29,18 +29,18 @@ module Fastlane
29
29
  end
30
30
  end
31
31
 
32
- def self.rsa_sign(timestamp, company_id, private_key)
32
+ def self.rsa_sign(timestamp, key_id, private_key)
33
33
  key = OpenSSL::PKey::RSA.new("-----BEGIN RSA PRIVATE KEY-----\n#{private_key}\n-----END RSA PRIVATE KEY-----")
34
- signature = key.sign(OpenSSL::Digest.new('SHA512'), company_id + timestamp)
34
+ signature = key.sign(OpenSSL::Digest.new('SHA512'), key_id + timestamp)
35
35
  Base64.encode64(signature)
36
36
  end
37
37
 
38
- def self.get_token(company_id:, private_key:)
38
+ def self.get_token(key_id:, private_key:)
39
39
  timestamp = DateTime.now.iso8601(3)
40
- signature = rsa_sign(timestamp, company_id, private_key)
40
+ signature = rsa_sign(timestamp, key_id, private_key)
41
41
  url = "/public/auth/"
42
42
  response = connection.post(url) do |req|
43
- req.body = { companyId: company_id, timestamp: timestamp, signature: signature }
43
+ req.body = { keyId: key_id, timestamp: timestamp, signature: signature }
44
44
  end
45
45
 
46
46
  UI.message("Debug: response #{response.body}") if ENV['DEBUG']
@@ -48,25 +48,25 @@ module Fastlane
48
48
  response.body["body"]["jwe"]
49
49
  end
50
50
 
51
- def self.create_draft(token, package_name, version_name)
51
+ def self.create_draft(token, package_name, publish_type)
52
52
  url = "/public/v1/application/#{package_name}/version"
53
53
  response = connection.post(url) do |req|
54
54
  req.headers['Public-Token'] = token
55
- req.body = { appName: version_name }
55
+ req.body = {}
56
+ req.body['publishType'] = publish_type unless publish_type.nil?
56
57
  end
57
58
 
58
59
  UI.message("Debug: response #{response.body}") if ENV['DEBUG']
59
-
60
- response.body["body"]
61
- end
62
-
63
- def self.delete_draft(token, draft_id, package_name)
64
- url = "/public/v1/application/#{package_name}/version/#{draft_id}"
65
- response = connection.delete(url) do |req|
66
- req.headers['Public-Token'] = token
60
+ if response.body["body"]
61
+ # Если черновика не было, и мы создали новый, здесь будет draftId
62
+ return response.body["body"]
63
+ elsif response.body["message"]
64
+ # Если черновик уже существовал, в message будет ошибка вида
65
+ # "You already have draft version with ID = XXXXXXXXXX", откуда достаем ID существующего черновика.
66
+ return response.body["message"].scan(/\d+/).first.to_i
67
+ else
68
+ raise "Couldn't get draftId from RuStore"
67
69
  end
68
-
69
- UI.message("Debug: response #{response.body}") if ENV['DEBUG']
70
70
  end
71
71
 
72
72
  def self.upload_apk(token, draft_id, is_hms, file_path, package_name)
@@ -79,14 +79,20 @@ module Fastlane
79
79
  end
80
80
 
81
81
  url = "/public/v1/application/#{package_name}/version/#{draft_id}/apk"
82
- payload = { servicesType: apk_type, isMainApk: is_main }
82
+ payload = {}
83
83
  payload[:file] = Faraday::Multipart::FilePart.new(file_path, 'application/vnd.android.package-archive')
84
84
 
85
85
  response = connection.post(url) do |req|
86
86
  req.headers['Public-Token'] = token
87
+ req.params['servicesType'] = apk_type
88
+ req.params['isMainApk'] = is_main
87
89
  req.body = payload
88
90
  end
89
91
 
92
+ if response.body["message"] == "File was not uploaded successfully: The code of this version must be larger than that of the previous one"
93
+ raise "Build with this version code was already uploaded earlier"
94
+ end
95
+
90
96
  UI.message("Debug: response #{response.body}") if ENV['DEBUG']
91
97
  end
92
98
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Rustore
3
- VERSION = "0.1.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-rustore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Onishchenko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2024-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- description:
153
+ description:
154
154
  email: pinkey.950@gmail.com
155
155
  executables: []
156
156
  extensions: []
@@ -166,7 +166,7 @@ homepage: https://github.com/stfbee/fastlane-plugin-rustore
166
166
  licenses:
167
167
  - MIT
168
168
  metadata: {}
169
- post_install_message:
169
+ post_install_message:
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib
@@ -181,8 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.4.10
185
- signing_key:
184
+ rubygems_version: 3.5.16
185
+ signing_key:
186
186
  specification_version: 4
187
187
  summary: Rustore fastlane integration plugin
188
188
  test_files: []