fastlane-plugin-icon_versioning 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af2fe2215c9a6960451b947740164d389b17117b
4
+ data.tar.gz: c4b6fbbce95d470bcee7162b8d91f8feb4ad8fa1
5
+ SHA512:
6
+ metadata.gz: 229ab7bda6fbad805756bfcbc7c059d5ecc2c204324e9e4b70405453c8394d4260d9b677ffe88a7b2902990cdf09bd05f603181614c110d3cfcaf06fa003c597
7
+ data.tar.gz: 53591f678340f55755aa926c51bac51706a3d21fba775a7ccaec25b320d0b9aa0cf4813c54fbd909c59fd5e1bbbfd8aad745aa5a9c133ff09e9b30121a4b65b0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Iulian Onofrei <6d0847b9@opayq.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,93 @@
1
+ # icon_versioning plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-icon_versioning)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-icon_versioning`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin icon_versioning
11
+ ```
12
+
13
+ ## About icon_versioning
14
+
15
+ Overlay build information on top of your app icon. Based on original work by Krzysztof Zabłocki (https://github.com/krzysztofzablocki/Bootstrap).
16
+
17
+ This copies the specified `.appiconset` folder to a new folder named `OriginalName-Versioned.appiconset` and overlays the specified `text` over the icon images inside it.
18
+
19
+ To automatically run this on every build, you can add a new `Run Script` `Build Phase` before the `Compile Sources` one and point it to a script that calls this plugin:
20
+
21
+ ![Run script](./assets/run_script.jpg)
22
+
23
+ _(Having a script file instead of the actual plugin call makes it easier to debug, change and review it, as explained in [this article](http://www.mokacoding.com/blog/better-build-phase-scripts/))_
24
+
25
+ ```sh
26
+ #!/usr/bin/env bash
27
+
28
+ # optional, to prevent versioning for release builds
29
+ if [[ $CONFIGURATION == "Release" ]]; then
30
+ exit 0
31
+ fi
32
+
33
+ # optional, to fix fastlane warnings that show up in the Report navigator
34
+ export LC_ALL=en_US.UTF-8
35
+ export LANG=en_US.UTF-8
36
+
37
+ # make sure Bundler is found
38
+ export GEM_HOME=~/.gems
39
+ export PATH=$PATH:$GEM_HOME/bin
40
+
41
+ export FASTLANE_DISABLE_COLORS=1 # optional, to remove from the build log the ANSI escape sequences that enables colors in terminal
42
+ export FASTLANE_SKIP_UPDATE_CHECK=1 # optional, to make sure that the versioning finishes as fast as possible in case there is an available update
43
+ export FASTLANE_HIDE_GITHUB_ISSUES=1 # optional, to make sure that the versioning finishes as fast as possible in case the plugin crashes
44
+
45
+ bundle exec fastlane run icon_versioning appiconset_path:'/path/to/AppIcon.appiconset' text:'1.2.3 (11.03.2018)\n[ead76f1] {Staging}\nmaster'
46
+ ```
47
+
48
+ In order for the new versioned icon to be actually used by the app, you have to point the `Asset Catalog App Icon Set Name` (`ASSETCATALOG_COMPILER_APPICON_NAME`) build setting to this new versioned one:
49
+
50
+ ![Build setting](./assets/build_setting.jpg)
51
+
52
+ Lastly, you should ignore the `-Versioned` folders using:
53
+
54
+ ```ini
55
+ /path/to/*-Versioned.appiconset/*
56
+ ```
57
+
58
+ In the end, it should look like this:
59
+
60
+ ![App icon](./assets/app_icon.jpg)
61
+
62
+ ## Example
63
+
64
+ 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`.
65
+
66
+ ## Run tests for this plugin
67
+
68
+ To run both the tests, and code style validation, run
69
+
70
+ ```
71
+ rake
72
+ ```
73
+
74
+ To automatically fix many of the styling issues, use
75
+ ```
76
+ rubocop -a
77
+ ```
78
+
79
+ ## Issues and Feedback
80
+
81
+ For any other issues and feedback about this plugin, please submit it to this repository.
82
+
83
+ ## Troubleshooting
84
+
85
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
86
+
87
+ ## Using _fastlane_ Plugins
88
+
89
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
90
+
91
+ ## About _fastlane_
92
+
93
+ _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/icon_versioning/version'
2
+
3
+ module Fastlane
4
+ module IconVersioning
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::IconVersioning.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,92 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/icon_versioning_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class IconVersioningAction < Action
7
+ def self.run(params)
8
+ icon_versioning_helper = Helper::IconVersioningHelper.new(params)
9
+
10
+ return icon_versioning_helper.run()
11
+ end
12
+
13
+ def self.description
14
+ 'Overlay build information on top of your app icon. Based on original work by Krzysztof Zabłocki (https://github.com/krzysztofzablocki/Bootstrap).'
15
+ end
16
+
17
+ def self.authors
18
+ ['Iulian Onofrei', 'Krzysztof Zabłocki']
19
+ end
20
+
21
+ def self.available_options
22
+ [
23
+ FastlaneCore::ConfigItem.new(
24
+ key: :appiconset_path,
25
+ env_name: 'ICON_VERSIONING_APPICONSET_PATH',
26
+ description: 'The path to the `.appiconset` directory containing the icon images',
27
+ verify_block: proc do |value|
28
+ path = File.expand_path(value.to_s)
29
+
30
+ UI.user_error!('Appiconset not found') unless File.exist?(path)
31
+ UI.user_error!('Appiconset is not a directory') unless File.directory?(path)
32
+ UI.user_error!('Appiconset does not end with .appiconset') unless path.end_with?('.appiconset')
33
+ end,
34
+ type: String
35
+ ),
36
+ FastlaneCore::ConfigItem.new(
37
+ key: :text,
38
+ env_name: 'ICON_VERSIONING_TEXT',
39
+ description: 'The text to overlay over the icon images',
40
+ type: String
41
+ ),
42
+ FastlaneCore::ConfigItem.new(
43
+ key: :band_height_percentage,
44
+ env_name: 'ICON_VERSIONING_BAND_HEIGHT_PERCENTAGE',
45
+ description: 'The percentage of the text band height relative to the image\'s height. A float number between 0 and 1',
46
+ default_value: 0.5,
47
+ verify_block: proc do |value|
48
+ UI.user_error!('Band height percentage is less than 0') if value < 0
49
+ UI.user_error!('Band height percentage is greater than 1') if value > 1
50
+ end,
51
+ optional: true,
52
+ type: Float
53
+ ),
54
+ FastlaneCore::ConfigItem.new(
55
+ key: :band_blur_radius_percentage,
56
+ env_name: 'ICON_VERSIONING_BAND_BLUR_RADIUS_PERCENTAGE',
57
+ description: 'The blur radius percentage of the text band. The default value behaves like an automatic setting which produces the best results. More details: http://www.imagemagick.org/Usage/blur/#blur_args',
58
+ default_value: 0,
59
+ verify_block: proc do |value|
60
+ UI.user_error!('Band blur radius percentage is less than 0') if value < 0
61
+ end,
62
+ optional: true,
63
+ type: Float
64
+ ),
65
+ FastlaneCore::ConfigItem.new(
66
+ key: :band_blur_sigma_percentage,
67
+ env_name: 'ICON_VERSIONING_BAND_BLUR_SIGMA_PERCENTAGE',
68
+ description: 'The blur sigma percentage of the text band. More details: http://www.imagemagick.org/Usage/blur/#blur_args',
69
+ default_value: 0.05,
70
+ verify_block: proc do |value|
71
+ UI.user_error!('Band blur sigma percentage is less than 0') if value < 0
72
+ UI.user_error!('Band blur sigma percentage is greater than 65355') if value > 65_355
73
+ end,
74
+ optional: true,
75
+ type: Float
76
+ ),
77
+ FastlaneCore::ConfigItem.new(
78
+ key: :ignored_icons_regex,
79
+ env_name: 'ICON_VERSIONING_IGNORED_ICONS_REGEX',
80
+ description: 'An optional regex that causes the icons that match agains it not to be versioned',
81
+ optional: true,
82
+ type: Regexp
83
+ )
84
+ ]
85
+ end
86
+
87
+ def self.is_supported?(platform)
88
+ [:ios].include?(platform)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,127 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'mini_magick'
3
+
4
+ module Fastlane
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
6
+
7
+ module Helper
8
+ class IconVersioningHelper
9
+ attr_accessor :appiconset_path
10
+ attr_accessor :text
11
+
12
+ attr_accessor :band_height_percentage
13
+ attr_accessor :band_blur_radius_percentage
14
+ attr_accessor :band_blur_sigma_percentage
15
+
16
+ attr_accessor :ignored_icons_regex
17
+
18
+ def initialize(params)
19
+ self.appiconset_path = File.expand_path(params[:appiconset_path])
20
+ self.text = params[:text]
21
+
22
+ self.band_height_percentage = params[:band_height_percentage]
23
+ self.band_blur_radius_percentage = params[:band_blur_radius_percentage]
24
+ self.band_blur_sigma_percentage = params[:band_blur_sigma_percentage]
25
+
26
+ self.ignored_icons_regex = params[:ignored_icons_regex]
27
+ end
28
+
29
+ def run()
30
+ versioned_appiconset_path = self.class.get_versioned_path(self.appiconset_path)
31
+
32
+ FileUtils.remove_entry(versioned_appiconset_path, force: true)
33
+ FileUtils.copy_entry(self.appiconset_path, versioned_appiconset_path)
34
+
35
+ Dir.glob("#{versioned_appiconset_path}/*.png").each do |icon_path|
36
+ next if self.ignored_icons_regex && !(icon_path =~ self.ignored_icons_regex).nil?
37
+
38
+ version_icon(icon_path)
39
+ end
40
+ end
41
+
42
+ def self.get_versioned_path(path)
43
+ return path.gsub(/([^.]+)(\.appiconset)/, '\1-Versioned\2')
44
+ end
45
+
46
+ private def version_icon(icon_path)
47
+ image = MiniMagick::Image.open(icon_path)
48
+
49
+ width = image[:width]
50
+ height = image[:height]
51
+
52
+ band_height = height * self.band_height_percentage
53
+ band_blur_radius = width * self.band_blur_radius_percentage
54
+ band_blur_sigma = width * self.band_blur_sigma_percentage
55
+
56
+ band_top_position = height - band_height
57
+
58
+ blurred_icon_path = suffix(icon_path, 'blurred')
59
+ mask_icon_path = suffix(icon_path, 'mask')
60
+ text_base_icon_path = suffix(icon_path, 'text_base')
61
+ text_icon_path = suffix(icon_path, 'text')
62
+ temp_icon_path = suffix(icon_path, 'temp')
63
+
64
+ MiniMagick::Tool::Convert.new do |convert|
65
+ convert << icon_path
66
+ convert << '-blur' << "#{band_blur_radius}x#{band_blur_sigma}"
67
+ convert << blurred_icon_path
68
+ end
69
+
70
+ MiniMagick::Tool::Convert.new do |convert|
71
+ convert << blurred_icon_path
72
+ convert << '-gamma' << '0'
73
+ convert << '-fill' << 'white'
74
+ convert << '-draw' << "rectangle 0, #{band_top_position}, #{width}, #{height}"
75
+ convert << mask_icon_path
76
+ end
77
+
78
+ MiniMagick::Tool::Convert.new do |convert|
79
+ convert << '-size' << "#{width}x#{band_height}"
80
+ convert << 'xc:none'
81
+ convert << '-fill' << 'rgba(0, 0, 0, 0.2)'
82
+ convert << '-draw' << "rectangle 0, 0, #{width}, #{band_height}"
83
+ convert << text_base_icon_path
84
+ end
85
+
86
+ MiniMagick::Tool::Convert.new do |convert|
87
+ convert << '-background' << 'none'
88
+ convert << '-size' << "#{width}x#{band_height}"
89
+ convert << '-fill' << 'white'
90
+ convert << '-gravity' << 'center'
91
+ # using label instead of caption prevents wrapping long lines
92
+ convert << "label:#{self.text}"
93
+ convert << text_icon_path
94
+ end
95
+
96
+ MiniMagick::Tool::Convert.new do |convert|
97
+ convert << icon_path
98
+ convert << blurred_icon_path
99
+ convert << mask_icon_path
100
+ convert << '-composite'
101
+ convert << temp_icon_path
102
+ end
103
+
104
+ File.delete(blurred_icon_path, mask_icon_path)
105
+
106
+ MiniMagick::Tool::Convert.new do |convert|
107
+ convert << temp_icon_path
108
+ convert << text_base_icon_path
109
+ convert << '-geometry' << "+0+#{band_top_position}"
110
+ convert << '-composite'
111
+ convert << text_icon_path
112
+ convert << '-geometry' << "+0+#{band_top_position}"
113
+ convert << '-composite'
114
+ convert << icon_path
115
+ end
116
+
117
+ File.delete(text_base_icon_path, text_icon_path, temp_icon_path)
118
+ end
119
+
120
+ private def suffix(path, text)
121
+ extension = File.extname(path)
122
+
123
+ return path.gsub(extension, "_#{text}#{extension}")
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module IconVersioning
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-icon_versioning
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Iulian Onofrei
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mini_magick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
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.84.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.84.0
153
+ description:
154
+ email: 6d0847b9@opayq.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/icon_versioning.rb
162
+ - lib/fastlane/plugin/icon_versioning/actions/icon_versioning_action.rb
163
+ - lib/fastlane/plugin/icon_versioning/helper/icon_versioning_helper.rb
164
+ - lib/fastlane/plugin/icon_versioning/version.rb
165
+ homepage: https://github.com/revolter/fastlane-plugin-icon_versioning
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.6.13
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Overlay build information on top of your app icon
189
+ test_files: []