fastlane-plugin-increment_version_code 0.3.1 → 0.4.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4861466762cdb494bb1be875b90495e1dc4790a3
|
4
|
+
data.tar.gz: b894fe24a67f76def65ca74addedb66881a4a498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f23831ca0b39fc26a1ec79211b6cf3b5615c84cd3d407b5e1b4eaf70b6ae087669e78150c26321a789dc92cccb4a2dc3545faca73f9d037f2a8e8ea97a21550
|
7
|
+
data.tar.gz: 28c7f16d273aae9cca2c5bfcda199bc98d83cf2f84585fd21af1461373021438ecc237a30300c1dab0b95f7da64262c8f8081596f8dc3a81523fdaa1b1adc244
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Jérémy TOUDIC <jeremy.toudic@gmail.com>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -5,68 +5,79 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class IncrementVersionCodeAction < Action
|
7
7
|
def self.run(params)
|
8
|
-
app_folder_name ||= params[:app_folder_name]
|
9
|
-
UI.message("The get_version_code plugin is looking inside your project folder (#{app_folder_name})!")
|
10
8
|
|
11
9
|
version_code = "0"
|
12
10
|
new_version_code ||= params[:version_code]
|
13
|
-
UI.message("new version code = #{new_version_code}")
|
14
11
|
|
15
|
-
|
16
|
-
foundVersionCode = "false"
|
17
|
-
Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
|
18
|
-
UI.message(" -> Found a build.gradle file at path: (#{path})!")
|
19
|
-
begin
|
20
|
-
temp_file = Tempfile.new('fastlaneIncrementVersionCode')
|
21
|
-
File.open(path, 'r') do |file|
|
22
|
-
file.each_line do |line|
|
23
|
-
if line.include? "versionCode " and foundVersionCode=="false"
|
12
|
+
constant_name ||= params[:ext_constant_name]
|
24
13
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
foundVersionCode = "true"
|
33
|
-
end
|
34
|
-
temp_file.puts line
|
35
|
-
else
|
36
|
-
temp_file.puts line
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
if foundVersionCode=="true"
|
41
|
-
break
|
42
|
-
end
|
43
|
-
file.close
|
44
|
-
end
|
45
|
-
temp_file.rewind
|
46
|
-
temp_file.close
|
47
|
-
FileUtils.mv(temp_file.path, path)
|
48
|
-
temp_file.unlink
|
49
|
-
ensure
|
50
|
-
if foundVersionCode=="true"
|
51
|
-
|
52
|
-
break
|
53
|
-
end
|
14
|
+
gradle_file_path ||= params[:gradle_file_path]
|
15
|
+
if gradle_file_path != nil
|
16
|
+
UI.message("The increment_version_code plugin will use gradle file at (#{gradle_file_path})!")
|
17
|
+
new_version_code = incrementVersion(gradle_file_path, new_version_code, constant_name)
|
18
|
+
else
|
19
|
+
app_folder_name ||= params[:app_folder_name]
|
20
|
+
UI.message("The get_version_code plugin is looking inside your project folder (#{app_folder_name})!")
|
54
21
|
|
22
|
+
#temp_file = Tempfile.new('fastlaneIncrementVersionCode')
|
23
|
+
#foundVersionCode = "false"
|
24
|
+
Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
|
25
|
+
UI.message(" -> Found a build.gradle file at path: (#{path})!")
|
26
|
+
new_version_code = incrementVersion(path, new_version_code, constant_name)
|
55
27
|
end
|
56
|
-
end
|
57
28
|
|
29
|
+
end
|
58
30
|
|
59
|
-
if
|
60
|
-
UI.user_error!("Impossible to find the version code
|
31
|
+
if new_version_code == -1
|
32
|
+
UI.user_error!("Impossible to find the version code with the specified properties 😭")
|
61
33
|
else
|
62
34
|
# Store the version name in the shared hash
|
63
35
|
Actions.lane_context["VERSION_CODE"]=new_version_code
|
64
|
-
UI.success("☝️ Version code has been changed
|
36
|
+
UI.success("☝️ Version code has been changed to #{new_version_code}")
|
65
37
|
end
|
66
38
|
|
67
39
|
return new_version_code
|
68
40
|
end
|
69
41
|
|
42
|
+
def self.incrementVersion(path, new_version_code, constant_name)
|
43
|
+
if !File.file?(path)
|
44
|
+
UI.message(" -> No file exist at path: (#{path})!")
|
45
|
+
return -1
|
46
|
+
end
|
47
|
+
begin
|
48
|
+
foundVersionCode = "false"
|
49
|
+
temp_file = Tempfile.new('fastlaneIncrementVersionCode')
|
50
|
+
File.open(path, 'r') do |file|
|
51
|
+
file.each_line do |line|
|
52
|
+
if line.include? constant_name and foundVersionCode=="false"
|
53
|
+
UI.message(" -> line: (#{line})!")
|
54
|
+
versionComponents = line.strip.split(' ')
|
55
|
+
version_code = versionComponents[versionComponents.length-1].tr("\"","")
|
56
|
+
if new_version_code <= 0
|
57
|
+
new_version_code = version_code.to_i + 1
|
58
|
+
end
|
59
|
+
if !!(version_code =~ /\A[-+]?[0-9]+\z/)
|
60
|
+
line.replace line.sub(version_code, new_version_code.to_s)
|
61
|
+
foundVersionCode = "true"
|
62
|
+
end
|
63
|
+
temp_file.puts line
|
64
|
+
else
|
65
|
+
temp_file.puts line
|
66
|
+
end
|
67
|
+
end
|
68
|
+
file.close
|
69
|
+
end
|
70
|
+
temp_file.rewind
|
71
|
+
temp_file.close
|
72
|
+
FileUtils.mv(temp_file.path, path)
|
73
|
+
temp_file.unlink
|
74
|
+
end
|
75
|
+
if foundVersionCode == "true"
|
76
|
+
return new_version_code
|
77
|
+
end
|
78
|
+
return -1
|
79
|
+
end
|
80
|
+
|
70
81
|
def self.description
|
71
82
|
"Increment the version code of your android project."
|
72
83
|
end
|
@@ -83,12 +94,24 @@ module Fastlane
|
|
83
94
|
optional: true,
|
84
95
|
type: String,
|
85
96
|
default_value:"app"),
|
97
|
+
FastlaneCore::ConfigItem.new(key: :gradle_file_path,
|
98
|
+
env_name: "INCREMENTVERSIONCODE_GRADLE_FILE_PATH",
|
99
|
+
description: "The relative path to the gradle file containing the version code parameter (default:app/build.gradle)",
|
100
|
+
optional: true,
|
101
|
+
type: String,
|
102
|
+
default_value: nil),
|
86
103
|
FastlaneCore::ConfigItem.new(key: :version_code,
|
87
104
|
env_name: "INCREMENTVERSIONCODE_VERSION_CODE",
|
88
105
|
description: "Change to a specific version (optional)",
|
89
106
|
optional: true,
|
90
107
|
type: Integer,
|
91
|
-
default_value: 0)
|
108
|
+
default_value: 0),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :ext_constant_name,
|
110
|
+
env_name: "INCREMENTVERSIONCODE_EXT_CONSTANT_NAME",
|
111
|
+
description: "If the version code is set in an ext constant, specify the constant name (optional)",
|
112
|
+
optional: true,
|
113
|
+
type: String,
|
114
|
+
default_value: "versionCode")
|
92
115
|
]
|
93
116
|
end
|
94
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-increment_version_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|