fastlane-plugin-setapp 0.1.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: 613aa7d761c259aca8e1f76481c55071004b502dcb1fdfe6bb55b4a034a84d8f
4
+ data.tar.gz: 417ac731d88fee7060ee3b9b8ac58e90f433a3d010418fcb61690ffc9a6b58ee
5
+ SHA512:
6
+ metadata.gz: 69293e53ca18d3007dac41d5998beb3d181ef323424612b0178d74f241e82aaa1ff53f10f4f5b1da8d4e7bc9e7543bdbfcc10689f46b61f33d56856e6518081e
7
+ data.tar.gz: f3b7f81ba6f0d091f80a0be5b80c5f3fc340ee269f42bcd8b717031c16a2fa18dbfbe0c96574a7338ed191701c59f85080d17ddf162a907aad9a70c33832668d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Setapp Limited.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # setapp plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-setapp)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with fastlane-plugin-setapp, you can either add it globally for all projects, or locally to an individual project.
8
+
9
+ ### Globally
10
+
11
+ If you install the gem globally, you can run it with any project that is setup for using `fastlane`.
12
+
13
+ ```bash
14
+ gem install fastlane-plugin-setapp
15
+ ```
16
+
17
+ Add the actions you want to use to your `Fastfile` file and call `fastlane` to run.
18
+
19
+ ### Locally
20
+
21
+ You can also add the plugin for individual projects. Navigate to your project where `fastlane` is already set up and run the following command:
22
+
23
+ ```bash
24
+ bundle exec fastlane add_plugin setapp
25
+ ```
26
+
27
+ Fastlane will guide you through the process. It will add a `Pluginfile` where the sentry plugin is listed and also update the `Gemfile` and `Gemfile.lock` to include it as a dependency.
28
+
29
+ ```ruby
30
+ # Autogenerated by fastlane
31
+ #
32
+ # Ensure this file is checked in to source control!
33
+
34
+ gem 'fastlane-plugin-setapp'
35
+ ```
36
+
37
+ Add the actions you want to use to your `Fastfile` file and call `bundle exec fastlane` to run.
38
+
39
+ ## Setapp actions
40
+
41
+ A subset of actions to upload new builds to Setapp.
42
+
43
+ ### Upload Setapp build
44
+
45
+ Uploads new version to Setapp and save it as a draft or send to a review process. You can add release notes for new build and specify if a version should be released right after approval.
46
+
47
+ ```ruby
48
+ upload_setapp_build(
49
+ api_token: '...', # Your Setapp API token
50
+ build_path: '...', # The path to archive with a new Setapp build
51
+ release_notes: '...', # Text or path to a file that contains release notes for a new version
52
+ version_status: review, # Version status. It can be `draft` or `review`
53
+ release_on_approval: true # Indicates whether Setapp must publish a new version after review
54
+ )
55
+ ```
56
+
57
+ ## Issues and Feedback
58
+
59
+ For any other issues and feedback about this plugin, please submit it to this repository.
60
+
61
+ ## Troubleshooting
62
+
63
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
64
+
65
+ ## Using _fastlane_ Plugins
66
+
67
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
68
+
69
+ ## About _fastlane_
70
+
71
+ _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).
@@ -0,0 +1,86 @@
1
+ require 'fastlane'
2
+ require_relative '../helper/setapp_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class UploadSetappBuildAction < Action
7
+ def self.run(params)
8
+ api_token = params[:api_token]
9
+ build_path = params[:build_path]
10
+ release_notes = params[:release_notes]
11
+ version_status = params[:version_status]
12
+ release_on_approval = params[:release_on_approval]
13
+ file_dir = File.dirname(__FILE__)
14
+ UI.user_error!("Available options for version_status: [draft, review].") unless ['draft', 'review'].include?(version_status)
15
+ UI.user_error!("Available options for release_on_approval: [true, false].") unless ['true', 'false'].include?(release_on_approval)
16
+ UI.message("The build at path #{build_path} will be uploaded to Setapp")
17
+ exit_code = system("bash #{file_dir}/../helper/setapp_build_uploader.sh --token #{api_token} --path #{build_path} --notes #{release_notes} --status #{version_status} --release-on-approval #{release_on_approval}")
18
+ UI.user_error!("Uploading error occured. Try again.") if exit_code != true
19
+ end
20
+
21
+ def self.description
22
+ "Upload new build to Setapp"
23
+ end
24
+
25
+ def self.authors
26
+ ["Setapp Limited"]
27
+ end
28
+
29
+ def self.return_value
30
+ end
31
+
32
+ def self.details
33
+ [
34
+ "If you chose the `draft` status, Setapp uploads the new build and saves it as a draft.",
35
+ "If you chose the `review`` status, Setapp sends the build for a review.",
36
+ "Read more information about app statuses in our documentation: https://docs.setapp.com/docs/checking-application-statuses"
37
+ ].join("\n")
38
+ end
39
+
40
+ def self.available_options
41
+ [
42
+ FastlaneCore::ConfigItem.new(
43
+ key: :api_token,
44
+ env_name: "SETAPP_API_TOKEN",
45
+ description: "Your Setapp API token",
46
+ optional: false,
47
+ sensitive: true,
48
+ type: String
49
+ ),
50
+ FastlaneCore::ConfigItem.new(
51
+ key: :build_path,
52
+ env_name: "SETAPP_BUILD_PATH",
53
+ description: "Path to an archive with a new bundle version",
54
+ optional: false,
55
+ type: String
56
+ ),
57
+ FastlaneCore::ConfigItem.new(
58
+ key: :release_notes,
59
+ env_name: "SETAPP_RELEASE_NOTES",
60
+ description: "Release notes for a new version. Add them as a plain text or as a path to file with text",
61
+ optional: false,
62
+ type: String
63
+ ),
64
+ FastlaneCore::ConfigItem.new(
65
+ key: :version_status,
66
+ env_name: "SETAPP_VERSION_STATUS",
67
+ description: "Select status for the uploaded build. Available options: `draft`, `review`",
68
+ optional: false,
69
+ type: String
70
+ ),
71
+ FastlaneCore::ConfigItem.new(
72
+ key: :release_on_approval,
73
+ env_name: "SETAPP_RELEASE_ON_APPROVAL",
74
+ description: "Indicate whether Setapp must release new version automatically after review. Available options: `true`, `false`",
75
+ optional: false,
76
+ type: String
77
+ )
78
+ ]
79
+ end
80
+
81
+ def self.is_supported?(platform)
82
+ true
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,134 @@
1
+ #!/bin/sh
2
+
3
+ msg() {
4
+ echo >&2 -e "${1-}"
5
+ }
6
+
7
+ die() {
8
+ local msg=$1
9
+ local code=${2-1} # default exit status 1
10
+ msg "$msg"
11
+ exit "$code"
12
+ }
13
+
14
+ function help() {
15
+ echo "
16
+ USAGE
17
+ $(basename "${BASH_SOURCE[0]}") [options...]
18
+
19
+ OPTIONS
20
+ -t, --token
21
+ Your Setapp token for continious integration.
22
+
23
+ -p, --path
24
+ Path to an archive with a new bundle version.
25
+
26
+ -n, -notes
27
+ Release notes for a new version. Add them as a plain text or as a path to file with text.
28
+
29
+ -s, --status
30
+ Choose a status for the build. You can save a new uploaded version as a draft and manage it from your Developer Account,
31
+ or you can send it on a review.
32
+ Available options: (draft/review)
33
+
34
+ -r, --release-on-approval
35
+ Indicate whether Setapp must publish a new version automatically after review approval.
36
+ Available options: (true/false)
37
+
38
+ -h, --help
39
+ Usage help
40
+ "
41
+ exit 0
42
+ }
43
+
44
+ function parse_params() {
45
+ local param
46
+ while [[ $# -gt 0 ]]; do
47
+ param="$1"
48
+ shift
49
+ case $param in
50
+ -h| --help)
51
+ help
52
+ exit 0
53
+ ;;
54
+ -t | --token)
55
+ if test $# -gt 0; then
56
+ api_token="${1}"
57
+ fi
58
+ shift;;
59
+ -p | --path)
60
+ if test $# -gt 0; then
61
+ archive_path="${1}"
62
+ fi
63
+ shift;;
64
+ -n | --notes)
65
+ if test $# -gt 0; then
66
+ release_notes="${1}"
67
+ if [[ -f "$release_notes" ]]; then
68
+ release_notes=$(cat "${release_notes}")
69
+ fi
70
+ fi
71
+ shift;;
72
+ -s | --status)
73
+ if test $# -gt 0; then
74
+ version_status="${1}"
75
+ fi
76
+ shift;;
77
+ -r | --release-on-approval)
78
+ if test $# -gt 0; then
79
+ release_on_approval="${1}"
80
+ fi
81
+ shift;;
82
+ *)
83
+ die "Invalid parameter was provided: $param" 1
84
+ ;;
85
+ esac
86
+ done
87
+ }
88
+
89
+ function check_parameters() {
90
+ [[ -z "${api_token}" ]] && die "Missing required parameter: api-token"
91
+ [[ -z "${archive_path}" ]] && die "Missing required parameter: archive-path"
92
+ [[ -z "${release_notes}" ]] && die "Missing required parameter: release-notes"
93
+ [[ -z "${version_status}" ]] && die "Missing required parameter: version-status"
94
+ [[ -z "${release_on_approval}" ]] && die "Missing required parameter: release-on-approval"
95
+ }
96
+
97
+ function validate_server_response() {
98
+ local server_response="${1}"
99
+ local response_code=${server_response##*HTTPSTATUS:}
100
+ local response_body=$(echo ${server_response%%HTTPSTATUS*})
101
+
102
+ if [ $response_code -eq 200 ]; then
103
+ echo "✅ The app version is uploaded. All checks are passed."
104
+ elif [ $response_code -eq 401 ]; then
105
+ die "⚠️ Something went wrong with your API token.\n${response_body}"
106
+ elif [ $response_code -eq 400 ]; then
107
+ die "🚨 Bundle validation error occured. See details in description below.\n${response_body}"
108
+ else
109
+ die "⛔️ Something went wrong. Server returned $response_code. See details in description below.\n${response_body}"
110
+ fi
111
+ }
112
+
113
+ function upload_binary() {
114
+ response=$(
115
+ curl -X POST "https://developer-api.setapp.com/v1/ci/version" \
116
+ --write-out "HTTPSTATUS:%{http_code}" \
117
+ -H "Authorization: Bearer ${api_token}" \
118
+ -H "accept: application/json" \
119
+ -H "Content-Type: multipart/form-data" \
120
+ -F "release_notes=${release_notes}" \
121
+ -F "status=${version_status}" \
122
+ -F "release_on_approval=${release_on_approval}" \
123
+ -F "archive=@${archive_path};type=application/zip"
124
+ )
125
+ validate_server_response "${response}"
126
+ }
127
+
128
+ function main() {
129
+ parse_params "$@"
130
+ check_parameters
131
+ upload_binary
132
+ }
133
+
134
+ main "$@"
@@ -0,0 +1,13 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
5
+
6
+ module Helper
7
+ class SetappHelper
8
+ def self.show_message
9
+ UI.message("Hello from the setapp plugin helper!")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Setapp
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require 'fastlane/plugin/setapp/version'
2
+
3
+ module Fastlane
4
+ module Setapp
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::Setapp.all_classes.each do |current|
12
+ require current
13
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-setapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Setapp Limited
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.211.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.211.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
154
+ email: developers@setapp.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/setapp.rb
162
+ - lib/fastlane/plugin/setapp/actions/upload_setapp_build.rb
163
+ - lib/fastlane/plugin/setapp/helper/setapp_build_uploader.sh
164
+ - lib/fastlane/plugin/setapp/helper/setapp_helper.rb
165
+ - lib/fastlane/plugin/setapp/version.rb
166
+ homepage:
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '2.6'
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubygems_version: 3.2.3
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Upload new version to Setapp
189
+ test_files: []