fastlane-plugin-get_last_circleci_build_number 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: 5d194a3ab97375c5daa0c3e0cba541132c4858513f3cb9ff391a5a142e608bfd
4
+ data.tar.gz: e907227be86fbce670f98a1b49ef6a4454adf7b828b7c49517799c46509abc27
5
+ SHA512:
6
+ metadata.gz: 7cc852ede1bbecba589ed2b39cec749507b615e4ff4f980650640ed81d0cd427e7120bc17f1becf150309e775aa777de3bcee1ac94b64b98f10987874a0d29a7
7
+ data.tar.gz: 5224966cd8fd44c08b069b8d0d8c19d41284eed2fd28869b05d00a913751f95deb7df4588d874016b6a003e9dd60497a6a1d3a868c4a318b8336561ccf7be14a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Dawid van der Hoven <dawidvdh@gmail.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.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # get_last_circleci_build_number plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-get_last_circleci_build_number)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-get_last_circleci_build_number`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin get_last_circleci_build_number
11
+ ```
12
+
13
+ Ensure you have the following enviroment variables set:
14
+
15
+ * `CIRCLECI_TOKEN` - your circleci token you can create one by getting a token from circle ci `Profile > Personal Api Tokens`
16
+ * `CIRCLECI_USER_NAME` - the username which owns the project
17
+ * `CIRCLECI_REPOSITORY` - the name of the repository
18
+
19
+ You should be able to find your repository name and user name on circleci when you enter into a project the url will be `https://app.circleci.com/projects/project-setup/github/dawidvdh/some-project` so in this case `dawidvdh` is my username and `some-project` is my project.
20
+
21
+ I typical use it in the projectg like so:
22
+
23
+ ```
24
+ before_all do |options, params|
25
+ Dotenv.overload '.env'
26
+ build_number = params[:build_number] || ENV["CIRCLE_BUILD_NUM"] || get_last_circleci_build_number
27
+ end
28
+ ```
29
+
30
+ where my `.env` contains `CIRCLECI_TOKEN`, `CIRCLECI_USER_NAME` and `CIRCLECI_REPOSITORY`.
31
+
32
+ ## About get_last_circleci_build_number
33
+
34
+ Makes user of [circleci gem] to fetch the last build number from circleci.
35
+
36
+ ## Issues and Feedback
37
+
38
+ For any other issues and feedback about this plugin, please submit it to this repository.
39
+
40
+ ## Troubleshooting
41
+
42
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
43
+
44
+ ## Using _fastlane_ Plugins
45
+
46
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
47
+
48
+ ## About _fastlane_
49
+
50
+ _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).
51
+
52
+ [circleci gem]: https://github.com/mtchavez/circleci
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/get_last_circleci_build_number/version'
2
+
3
+ module Fastlane
4
+ module GetLastCircleciBuildNumber
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions}/*.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::GetLastCircleciBuildNumber.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,87 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class GetLastCircleciBuildNumberAction < Action
6
+ def self.run(params)
7
+ Actions.verify_gem!('circleci')
8
+ require 'circleci'
9
+ configure(params)
10
+ get
11
+ end
12
+
13
+ def self.token(params)
14
+ token = params[:api_token].nil? ? ENV['CIRCLECI_TOKEN'] : params[:api_token]
15
+ CircleCi.configure do |config|
16
+ config.token = token
17
+ end
18
+ token
19
+ end
20
+
21
+ def self.configure(params)
22
+ @token = params[:api_token].nil? ? ENV['CIRCLECI_TOKEN'] : params[:api_token]
23
+ @user = params[:user_name].nil? ? ENV['CIRCLECI_USER_NAME'] : params[:user_name]
24
+ @repository = params[:repository].nil? ? ENV['CIRCLECI_REPOSITORY'] : params[:repository]
25
+
26
+ CircleCi.configure do |config|
27
+ config.token = @token
28
+ end
29
+
30
+ UI.user_error! "Set CIRCLECI_TOKEN" if @token.nil? || @token.empty?
31
+ UI.user_error! "Set CIRCLECI_USER_NAME" if @user.nil? || @user.empty?
32
+ UI.user_error! "Set CIRCLECI_REPOSITORY" if @repository.nil? || @repository.empty?
33
+ UI.message "Access to #{@user}/#{@repository}"
34
+ end
35
+
36
+ def self.get
37
+ project = CircleCi::Project.new @user, @repository
38
+ res = project.recent_builds limit: 1
39
+ build_num = res.body.map do |e|
40
+ e['build_num']
41
+ end
42
+
43
+ Actions.lane_context[SharedValues::GET_LAST_CIRCLECI_BUILD_NUMBER] = build_num[0].to_i
44
+ end
45
+
46
+ def self.description
47
+ "fetches the last build number from circleci."
48
+ end
49
+
50
+ def self.authors
51
+ ["Dawid van der Hoven"]
52
+ end
53
+
54
+ def self.return_value
55
+ "the last build number from circleci as a string"
56
+ end
57
+
58
+ def self.details
59
+ "Fetches that last build number from circleci using the circleci gem, useful for local builds when the project uses the circleci build number as the version build number."
60
+ end
61
+
62
+ def self.available_options
63
+ [
64
+ FastlaneCore::ConfigItem.new(key: :api_token,
65
+ env_name: "CIRCLECI_TOKEN",
66
+ description: "API Token for Circle CI",
67
+ type: String,
68
+ optional: true),
69
+ FastlaneCore::ConfigItem.new(key: :user_name,
70
+ env_name: "CIRCLECI_USER_NAME",
71
+ description: "user name for Circle CI",
72
+ type: String,
73
+ optional: true),
74
+ FastlaneCore::ConfigItem.new(key: :repository,
75
+ env_name: "CIRCLECI_REPOSITORY",
76
+ description: "repository for Circle CI",
77
+ type: String,
78
+ optional: true)
79
+ ]
80
+ end
81
+
82
+ def self.is_supported?(platform)
83
+ [:ios, :mac, :android].include?(platform)
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module GetLastCircleciBuildNumber
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-get_last_circleci_build_number
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dawid van der Hoven
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
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: bundler
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: rspec
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_junit_formatter
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: rake
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: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
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: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.142.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.142.0
139
+ description:
140
+ email: dawidvdh@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/get_last_circleci_build_number.rb
148
+ - lib/fastlane/plugin/get_last_circleci_build_number/actions/get_last_circleci_build_number_action.rb
149
+ - lib/fastlane/plugin/get_last_circleci_build_number/version.rb
150
+ homepage: https://github.com/dawidvdh/get_last_circleci_build_number
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.1.2
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: fetches the last build number from circleci.
173
+ test_files: []