fastlane-plugin-react_native_release 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 41c9108af617444663430f462d96375ee2a4856e083553a7f935699cbdf01211
4
+ data.tar.gz: 8c6c46cb031b6af0204af69c59e5d3526ce04eac969ea4d84d9c414cf00c0b91
5
+ SHA512:
6
+ metadata.gz: 38c95c3c03ebe145a5e2174910bfc261513c01dc15d9abe372e34b0a0d9cd0a552687a7c4c4acff281d41e143434e42ec02af706765945527ddb5c8e142f8c32
7
+ data.tar.gz: 2869253f1d4a9e852b1d05e43a401218e439498f0818fa6d13b52000cfb0a2eb8e4e46e5ad12a0ac2a17272594789de9d23becdd4163cfa2cd39587328f8c2d4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Chris Ball <chris@echobind.com>
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.
@@ -0,0 +1,83 @@
1
+ # React Native Release
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-react_native_release)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-react_native_release`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin react_native_release
11
+ ```
12
+
13
+ ### Ensure your project confirms to Semantic Versioning
14
+ Projects using React Native Release should use Semantic Versioning. At the very least, you need major, minor, and patch numbers in your version.
15
+
16
+ **iOS**
17
+ Use `agvtool` to get and set a version across your project. From the `ios` directory, do the following:
18
+ * `agvtool what-marketing-version` to see your current version
19
+ * `agvtool new-marketing-version 0.1.0` to set a new version
20
+
21
+ **Android**
22
+ * Set `versionName` in `app/build.gradle`. (`versionName "0.1.0"`)
23
+
24
+ :exclamation: If you don't complete these steps, releases will fail. :exclamation:
25
+
26
+ ## About React Native Release
27
+
28
+ Simplify releases for React Native apps.
29
+
30
+ This plugin:
31
+
32
+ - cuts a new `beta` or `production` release
33
+ - prompts the user for a `major/minor/patch` version bump
34
+ - bumps the version of the iOS and Android app appropriately
35
+ - tags a release based on the iOS and Android version
36
+ - handles hotfix releases
37
+ - handles merging version bumps and hotfixes back to the appropriate branches
38
+
39
+ The main branch and tagging flow looks like this:
40
+ ![Branch / Tag Flow](https://monosnap.com/image/Tn71leeWdCwwjSdwjYKHK4pnyjG1v4.png)
41
+
42
+ If a hotfix is required the flow looks like this:
43
+ ![Hotfix Flow](https://monosnap.com/image/ctwlef0A3TbLbRk1xJrlVroNB8F9ot.png)
44
+
45
+ Here's what it looks like in action:
46
+ ![Releasing a beta](https://api.monosnap.com/image/download?id=IEISpG4vgMeGPl31it8GxPbiTror2i)
47
+ (this example uses `"release": "bundle exec fastlane run react_native_release"` as a yarn script)
48
+
49
+ ## Example
50
+
51
+ 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`.
52
+
53
+ **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)
54
+
55
+ ## Run tests for this plugin
56
+
57
+ To run both the tests, and code style validation, run
58
+
59
+ ```
60
+ rake
61
+ ```
62
+
63
+ To automatically fix many of the styling issues, use
64
+
65
+ ```
66
+ rubocop -a
67
+ ```
68
+
69
+ ## Issues and Feedback
70
+
71
+ For any other issues and feedback about this plugin, please submit it to this repository.
72
+
73
+ ## Troubleshooting
74
+
75
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
76
+
77
+ ## Using _fastlane_ Plugins
78
+
79
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
80
+
81
+ ## About _fastlane_
82
+
83
+ _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,16 @@
1
+ require 'fastlane/plugin/react_native_release/version'
2
+
3
+ module Fastlane
4
+ module ReactNativeRelease
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::ReactNativeRelease.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,209 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/react_native_release_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class ReactNativeReleaseAction < Action
7
+ VALID_TARGETS = %w{beta production}
8
+
9
+ def self.run(params)
10
+ require 'fastlane/plugin/android_versioning'
11
+ target = UI.select "Select a release type:", VALID_TARGETS
12
+ is_beta = target.include?('beta')
13
+ is_hotfix = params[:hotfix] === true
14
+ ios_version = other_action.get_version_number(xcodeproj: params[:xcodeproj], target: File.basename(params[:xcodeproj], '.*'))
15
+ android_version = other_action.get_version_name(app_project_dir: params[:android_app_dir])
16
+ should_prompt_for_version_bump = params[:prompt_for_version_bump] === true || is_beta
17
+
18
+ if is_beta
19
+ tag_prefix = 'betas'
20
+ base_branch = params[:alpha_branch]
21
+ target_branch = params[:beta_branch]
22
+ else
23
+ tag_prefix = 'releases'
24
+ base_branch = params[:beta_branch]
25
+ target_branch = params[:production_branch]
26
+ end
27
+
28
+ # Ensure we're on the right branch and in a good state
29
+ other_action.ensure_git_branch(branch: base_branch)
30
+ other_action.ensure_git_status_clean
31
+ sh "git branch --set-upstream-to=origin/#{base_branch} #{base_branch}"
32
+ other_action.git_pull
33
+
34
+ # Cut a fresh branch unless this is a hotfix
35
+ if !is_hotfix
36
+ # delete an existing branch if we have one
37
+ sh "git show-ref #{target_branch}" do |status|
38
+ sh "git branch -D #{target_branch}" if status.success?
39
+ end
40
+
41
+ sh "git checkout -b #{target_branch}"
42
+ end
43
+
44
+ # Tag / Bump version
45
+ if should_prompt_for_version_bump
46
+ version = prompt_for_version
47
+ ios_version = bump_ios_version(version: version, xcodeproj: params[:xcodeproj])
48
+ android_version = bump_android_version(version: version)
49
+
50
+ if ios_version && android_version
51
+ UI.message "Committing iOS v#{ios_version} and Android v#{android_version} to git"
52
+ other_action.git_commit(
53
+ path: ["#{Dir.pwd}/ios", "#{Dir.pwd}/android"],
54
+ message: "Release iOS v#{ios_version} and Android v#{android_version}"
55
+ )
56
+ else
57
+ UI.message "No version bump specified"
58
+ end
59
+ end
60
+
61
+ # Tag it
62
+ tag_name = "#{tag_prefix}/ios-#{ios_version}-android-#{android_version}"
63
+ other_action.add_git_tag(tag: tag_name)
64
+ other_action.push_to_git_remote(
65
+ local_branch: target_branch,
66
+ force: true
67
+ )
68
+
69
+ merge_branch(branch: target_branch, target: base_branch)
70
+ return if is_beta
71
+
72
+ # production releases need an additional merge back to the alpha branch
73
+ merge_branch(branch: params[:beta_branch], target: params[:alpha_branch])
74
+ end
75
+
76
+ # Handles merging the specified branch into a target.
77
+ # example: beta -> master
78
+ def self.merge_branch(options)
79
+ branch = options[:branch]
80
+ target = options[:target]
81
+
82
+ sh "git checkout #{target}"
83
+ sh "git merge origin/#{branch}" do |status|
84
+ unless status.success?
85
+ UI.error "Failed to merge #{branch} into #{target}"
86
+ end
87
+
88
+ other_action.push_to_git_remote(
89
+ local_branch: target
90
+ )
91
+ end
92
+ end
93
+
94
+ def self.bump_ios_version(options)
95
+ version_bump = options[:version] || prompt_for_version
96
+ return if version_bump == "none"
97
+
98
+ UI.message "bumping ios #{options[:xcodeproj]} to #{version_bump}"
99
+ other_action.increment_version_number(
100
+ xcodeproj: options[:xcodeproj],
101
+ bump_type: version_bump
102
+ )
103
+ end
104
+
105
+ def self.bump_android_version(options)
106
+ version_bump = options[:version] || prompt_for_version
107
+ return if version_bump == "none"
108
+
109
+ UI.message "bumping android to #{version_bump}"
110
+ other_action.increment_version_name(
111
+ # TODO: make param
112
+ app_project_dir: "#{Dir.pwd}/android/app",
113
+ bump_type: version_bump
114
+ )
115
+ end
116
+
117
+ def self.prompt_for_version
118
+ UI.select("Update Version?: ", ["none", "major", "minor", "patch"])
119
+ end
120
+
121
+ def self.description
122
+ "Simplify releases for React Native apps"
123
+ end
124
+
125
+ def self.authors
126
+ ["cball"]
127
+ end
128
+
129
+ def self.return_value
130
+ # If your method provides a return value, you can describe here what it does
131
+ end
132
+
133
+ def self.details
134
+ "Creates a release for a React Native app. Handles incrementing versions and tags"
135
+ end
136
+
137
+ def self.available_options
138
+ [
139
+ FastlaneCore::ConfigItem.new(key: :xcodeproj,
140
+ env_name: "REACT_NATIVE_RELEASE_XCODE_PROJECT",
141
+ description: "Path to Xcode project",
142
+ optional: true,
143
+ type: String,
144
+ default_value: "#{Dir.pwd}/#{Dir['**/*.xcodeproj'].sort.first}",
145
+ verify_block: lambda do |value|
146
+ UI.user_error!("Could not find Xcode project") unless File.exist?(value)
147
+ end),
148
+ FastlaneCore::ConfigItem.new(key: :android_app_dir,
149
+ env_name: "REACT_NATIVE_RELEASE_ANDROID_APP_DIR",
150
+ description: "Path to Android app dir",
151
+ optional: true,
152
+ type: String,
153
+ default_value: "#{Dir.pwd}/android/app",
154
+ verify_block: lambda do |value|
155
+ UI.user_error!("Could not find specified Android app dir") unless File.exist?(value)
156
+ end),
157
+ FastlaneCore::ConfigItem.new(key: :alpha_branch,
158
+ env_name: "REACT_NATIVE_RELEASE_ALPHA_BRANCH",
159
+ description: "The branch used for alpha releases",
160
+ optional: true,
161
+ type: String,
162
+ default_value: 'master'),
163
+ FastlaneCore::ConfigItem.new(key: :beta_branch,
164
+ env_name: "REACT_NATIVE_RELEASE_BETA_BRANCH",
165
+ description: "The branch used for beta releases",
166
+ optional: true,
167
+ type: String,
168
+ default_value: 'beta'),
169
+ FastlaneCore::ConfigItem.new(key: :production_branch,
170
+ env_name: "REACT_NATIVE_RELEASE_PRODUCTION_BRANCH",
171
+ description: "The branch used for production releases",
172
+ optional: true,
173
+ type: String,
174
+ default_value: 'production'),
175
+ FastlaneCore::ConfigItem.new(key: :target,
176
+ env_name: "REACT_NATIVE_RELEASE_TARGET",
177
+ description: "The release target. Valid targets are #{VALID_TARGETS.join(', ')}",
178
+ optional: true,
179
+ type: String,
180
+ verify_block: lambda do |value|
181
+ unless VALID_TARGETS.find{|v| value == v}
182
+ UI.user_error!("Invalid target #{value}. Valid targets are #{VALID_TARGETS.join(', ')}")
183
+ next
184
+ end
185
+ end),
186
+ FastlaneCore::ConfigItem.new(key: :hotfix,
187
+ env_name: "REACT_NATIVE_RELEASE_HOTFIX",
188
+ description: "If this is a hotfix. Will only pull the latest branch and tag",
189
+ optional: true,
190
+ type: Boolean,
191
+ default_value: false),
192
+ FastlaneCore::ConfigItem.new(key: :prompt_for_version_bump,
193
+ env_name: "REACT_NATIVE_RELEASE_PROMPT_FOR_VERSION_BUMP",
194
+ description: "Force the prompt to bump the app version. Otherwise, only prompts on beta",
195
+ optional: true,
196
+ type: Boolean,
197
+ default_value: false),
198
+ ]
199
+ end
200
+
201
+ def self.is_supported?(platform)
202
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
203
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
204
+ #
205
+ [:ios, :android].include?(platform)
206
+ end
207
+ end
208
+ end
209
+ end
@@ -0,0 +1,16 @@
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 ReactNativeReleaseHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::ReactNativeReleaseHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the react_native_release plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module ReactNativeRelease
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-react_native_release
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Ball
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fastlane-plugin-android_versioning
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
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: rspec
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_junit_formatter
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: rake
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: 0.49.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.49.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-require_tools
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: simplecov
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: fastlane
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.112.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.112.0
153
+ description:
154
+ email: chris@echobind.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/react_native_release.rb
162
+ - lib/fastlane/plugin/react_native_release/actions/react_native_release_action.rb
163
+ - lib/fastlane/plugin/react_native_release/helper/react_native_release_helper.rb
164
+ - lib/fastlane/plugin/react_native_release/version.rb
165
+ homepage:
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.7.6
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Simplify releases for React Native apps.
189
+ test_files: []