fastlane-plugin-appforshare 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aee20a5b8c8408a2f2c378c1505861079a8d105a8b02349ef6b2eb5224825ed0
4
+ data.tar.gz: fc0dd2c5963ea01feadd098cc60f503e912d7204deeda3fb0d8ec6b1c5f1f53e
5
+ SHA512:
6
+ metadata.gz: a5134d0a31ed40d12f0be48c44e9aa1ec79d77328a7d02dce515e64bb8b3317f5878a8f1ce367273075ec03bde8795080778b14c7c1f7dec3cb1b8f60cccef69
7
+ data.tar.gz: 00356bda06a9a8418525a13243de865d83ab7c32a1a92a53a67c6fe2d0bf68fd4a6699c0bc8965a78d6344336f53a5ed0a3af081168d24aeede6e13c9a52087a
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AppForShare
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation
7
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of
11
+ the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # fastlane-plugin-appforshare
2
+
3
+ Upload iOS (.ipa) and Android (.apk) builds to [AppForShare](https://appforshare.io) from fastlane and get an
4
+ install link and QR code page for your testers.
5
+
6
+ ```sh
7
+ fastlane add_plugin appforshare
8
+ ```
9
+
10
+ ```ruby
11
+ lane :beta do
12
+ gym(export_method: "ad-hoc")
13
+ appforshare(release_notes: "Fixes the login crash", fail_on: "blocked")
14
+ slack(message: "New build: #{lane_context[SharedValues::APPFORSHARE_URL]}")
15
+ end
16
+ ```
17
+
18
+ Set `APPFORSHARE_TOKEN` (Dashboard, Settings, API tokens; Pro and Team plans). Without `file:` the action takes
19
+ the build from gym (`IPA_OUTPUT_PATH`) or gradle (`GRADLE_APK_OUTPUT_PATH`).
20
+
21
+ | Option | Env | |
22
+ |---|---|---|
23
+ | `api_token` | `APPFORSHARE_TOKEN` | API token |
24
+ | `file` | `APPFORSHARE_FILE` | .ipa or .apk |
25
+ | `release_notes` | `APPFORSHARE_RELEASE_NOTES` | Shown to testers (Pro and Team) |
26
+ | `fail_on` | `APPFORSHARE_FAIL_ON` | `blocked` or `review`: fail the lane on the store readiness check. The build stays uploaded. |
27
+
28
+ Lane context after the action: `APPFORSHARE_URL`, `APPFORSHARE_SLUG`, `APPFORSHARE_READINESS`. The store readiness
29
+ check is guidance about current App Store and Google Play rules, not a promise of approval.
30
+
31
+ MIT license. Source: https://github.com/appforshare/fastlane-plugin-appforshare
@@ -0,0 +1,98 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/client'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ APPFORSHARE_URL = :APPFORSHARE_URL
8
+ APPFORSHARE_SLUG = :APPFORSHARE_SLUG
9
+ APPFORSHARE_READINESS = :APPFORSHARE_READINESS
10
+ end
11
+
12
+ class AppforshareAction < Action
13
+ def self.run(params)
14
+ file = params[:file]
15
+ UI.user_error!('No build to upload. Pass file: or run gym / gradle first.') unless file && File.exist?(file)
16
+ client = Helper::AppforshareClient.new(token: params[:api_token], api: params[:api_url], log: ->(m) { UI.message(m) })
17
+ status = client.upload(file, notes: params[:release_notes])
18
+ readiness = 'unknown'
19
+ findings = []
20
+ begin
21
+ detail = client.build(status['slug'])
22
+ readiness = detail.dig('readinessReport', 'status') || 'unknown'
23
+ findings = detail.dig('readinessReport', 'findings') || []
24
+ rescue Helper::AppforshareClient::Error => e
25
+ raise if params[:fail_on]
26
+
27
+ UI.important("Store readiness not read: #{e.message}")
28
+ end
29
+ Actions.lane_context[SharedValues::APPFORSHARE_URL] = status['url']
30
+ Actions.lane_context[SharedValues::APPFORSHARE_SLUG] = status['slug']
31
+ Actions.lane_context[SharedValues::APPFORSHARE_READINESS] = readiness
32
+ UI.success("Install link: #{status['url']}")
33
+ UI.message("Store readiness: #{readiness}")
34
+ findings.each { |f| UI.important("[#{f['level']}] #{f['title']}: #{f['fix']}") }
35
+ fail_on = params[:fail_on]
36
+ if (fail_on == 'blocked' && readiness == 'blocked') || (fail_on == 'review' && %w[blocked review].include?(readiness))
37
+ UI.user_error!("Store readiness is \"#{readiness}\" (fail_on: #{fail_on}). The build is uploaded and its link works: #{status['url']}")
38
+ end
39
+ status['url']
40
+ rescue Helper::AppforshareClient::Error => e
41
+ UI.user_error!(e.message)
42
+ end
43
+
44
+ def self.description
45
+ 'Upload an .ipa or .apk to AppForShare and get an install link for testers'
46
+ end
47
+
48
+ def self.details
49
+ 'Uploads in 32 MB chunks (resumes after a dropped connection), waits until the build is ready, returns the ' \
50
+ 'install link and reads the store readiness check. Needs an AppForShare API token (Pro and Team plans).'
51
+ end
52
+
53
+ def self.authors
54
+ ['AppForShare']
55
+ end
56
+
57
+ def self.return_value
58
+ 'The install link'
59
+ end
60
+
61
+ def self.output
62
+ [
63
+ ['APPFORSHARE_URL', 'Install link'],
64
+ ['APPFORSHARE_SLUG', 'Share code of the build'],
65
+ ['APPFORSHARE_READINESS', 'Store readiness status: ready, review, blocked or unknown']
66
+ ]
67
+ end
68
+
69
+ def self.available_options
70
+ [
71
+ FastlaneCore::ConfigItem.new(key: :api_token, env_name: 'APPFORSHARE_TOKEN', description: 'AppForShare API token (Dashboard, Settings)', sensitive: true, optional: false),
72
+ FastlaneCore::ConfigItem.new(key: :file, env_name: 'APPFORSHARE_FILE', description: 'Path to the .ipa or .apk', optional: true,
73
+ default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] || Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
74
+ default_value_dynamic: true),
75
+ FastlaneCore::ConfigItem.new(key: :release_notes, env_name: 'APPFORSHARE_RELEASE_NOTES', description: 'Release notes shown to testers (Pro and Team)', optional: true),
76
+ FastlaneCore::ConfigItem.new(key: :fail_on, env_name: 'APPFORSHARE_FAIL_ON', description: 'Fail the lane when store readiness is "blocked", or "review"', optional: true,
77
+ verify_block: proc { |v| UI.user_error!('fail_on takes "blocked" or "review"') unless %w[blocked review].include?(v) }),
78
+ FastlaneCore::ConfigItem.new(key: :api_url, env_name: 'APPFORSHARE_API', description: 'API origin', optional: true, default_value: 'https://appforshare.io')
79
+ ]
80
+ end
81
+
82
+ def self.example_code
83
+ [
84
+ 'appforshare(release_notes: "Fixes the login crash")',
85
+ 'appforshare(file: "app/build/outputs/apk/release/app-release.apk", fail_on: "blocked")'
86
+ ]
87
+ end
88
+
89
+ def self.category
90
+ :beta
91
+ end
92
+
93
+ def self.is_supported?(platform)
94
+ %i[ios android].include?(platform)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,84 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ module Fastlane
6
+ module Helper
7
+ # Same resumable upload API as the website and the npm CLI: create, PUT chunks at offsets, complete, poll.
8
+ class AppforshareClient
9
+ class Error < StandardError; end
10
+
11
+ def initialize(token:, api: 'https://appforshare.io', log: nil)
12
+ @token = token
13
+ @api = api.sub(%r{/+\z}, '')
14
+ @log = log || ->(_msg) {}
15
+ end
16
+
17
+ def upload(path, notes: nil)
18
+ size = File.size(path)
19
+ body = { fileName: File.basename(path), size: size }
20
+ body[:releaseNotes] = notes[0, 5000] if notes && !notes.empty?
21
+ created = request(:post, '/uploads', json: body)
22
+ @log.call("Uploading #{File.basename(path)} (#{format('%.1f', size / 1024.0 / 1024)} MB)")
23
+ offset = created['offset'] || 0
24
+ headers = { 'X-Upload-Token' => created['token'] }
25
+ File.open(path, 'rb') do |f|
26
+ while offset < size
27
+ f.seek(offset)
28
+ chunk = f.read([created['chunkBytes'], size - offset].min)
29
+ res = request(:put, "/uploads/#{created['id']}?offset=#{offset}", body: chunk, headers: headers)
30
+ offset = res['offset'].is_a?(Integer) ? res['offset'] : offset + chunk.bytesize
31
+ end
32
+ end
33
+ request(:post, "/uploads/#{created['id']}/complete", headers: headers)
34
+ deadline = Time.now + 20 * 60
35
+ loop do
36
+ s = request(:get, "/uploads/#{created['id']}", headers: headers)
37
+ raise Error, (s['error'] || 'The build could not be processed.') if s['status'] == 'FAILED'
38
+ return s if s['status'] == 'READY'
39
+ raise Error, 'Processing is taking too long. Check your dashboard.' if Time.now > deadline
40
+
41
+ sleep 2
42
+ end
43
+ end
44
+
45
+ def build(ref)
46
+ request(:get, "/ci/builds/#{URI.encode_www_form_component(ref)}")
47
+ end
48
+
49
+ def request(method, path, json: nil, body: nil, headers: {})
50
+ uri = URI("#{@api}/api#{path}")
51
+ attempt = 0
52
+ begin
53
+ attempt += 1
54
+ req = { get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }[method].new(uri)
55
+ req['Authorization'] = "Bearer #{@token}"
56
+ req['User-Agent'] = "fastlane-plugin-appforshare/#{Fastlane::Appforshare::VERSION}"
57
+ headers.each { |k, v| req[k] = v }
58
+ if json
59
+ req['Content-Type'] = 'application/json'
60
+ req.body = JSON.generate(json)
61
+ elsif body
62
+ req['Content-Type'] = 'application/octet-stream'
63
+ req.body = body
64
+ end
65
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', read_timeout: 300) { |http| http.request(req) }
66
+ data = res.body && !res.body.empty? ? (JSON.parse(res.body) rescue {}) : {}
67
+ code = res.code.to_i
68
+ raise IOError, "HTTP #{code}" if code >= 500 && attempt < 6
69
+ offset_reply = code == 400 && data['offset'].is_a?(Integer)
70
+ unless (200..299).cover?(code) || code == 409 || offset_reply
71
+ msg = data['message'].is_a?(Array) ? data['message'].first : data['message']
72
+ raise Error, (msg || "Request failed with #{code}")
73
+ end
74
+ data
75
+ rescue IOError, SystemCallError, Net::OpenTimeout, Net::ReadTimeout, OpenSSL::SSL::SSLError => e
76
+ raise Error, "Network error: #{e.message}" if attempt >= 6
77
+
78
+ sleep [30, 2**attempt].min
79
+ retry
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Appforshare
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'fastlane/plugin/appforshare/version'
2
+
3
+ module Fastlane
4
+ module Appforshare
5
+ def self.all_classes
6
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
7
+ end
8
+ end
9
+ end
10
+
11
+ Fastlane::Appforshare.all_classes.each { |current| require current }
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-appforshare
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - AppForShare
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-10-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Fastlane action that uploads an .ipa or .apk to AppForShare (appforshare.io),
14
+ waits for it to be ready, returns the install link and the store readiness status,
15
+ and can fail the lane on readiness blockers.
16
+ email: support@appforshare.io
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - lib/fastlane/plugin/appforshare.rb
24
+ - lib/fastlane/plugin/appforshare/actions/appforshare_action.rb
25
+ - lib/fastlane/plugin/appforshare/helper/client.rb
26
+ - lib/fastlane/plugin/appforshare/version.rb
27
+ homepage: https://appforshare.io/docs/ci
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ homepage_uri: https://appforshare.io/docs/ci
32
+ source_code_uri: https://github.com/appforshare/fastlane-plugin-appforshare
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '2.6'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.5.22
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Upload iOS and Android builds to AppForShare and get an install link for
52
+ testers.
53
+ test_files: []