lhj-tools 0.2.55 → 0.2.57

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68770ecdc2bcbbaf11c4abb141a369a5c29db2cc259a5611380c21d19b1f4e6d
4
- data.tar.gz: 7f140ea8851f5b4e3d8bb7580f6a026af755daedcf29b3afaaaf12ffc339bb35
3
+ metadata.gz: 1522e2e897fadad490a8c1b9baaff75d7472a3d7deeadf7bdb790ff310bcd56d
4
+ data.tar.gz: fa96344cdf3abd706ac13f0b349a3c9b0eb3e745d4da0befb1dc0ef4fcc0d57f
5
5
  SHA512:
6
- metadata.gz: 65042d867dd01f4a6758932c4739e346292fe87013e91a4fa7c6b620b63a954e0a8b2b73e13e327d95b6bda55dacbc759d7bcff384373d488ed78619813de735
7
- data.tar.gz: '0729678a05e7e8502ddf70489bfb8517677b155ec5767223eeb21c8179b489d78eaeeaef005faaa673cbf414068c4afbc07033d4d5db4b4cfc78ecacebe295ad'
6
+ metadata.gz: f8c8b06eb183abc0969c0ec0d09fccff56c2977ccc3f55923e49180759ac36dbce014f1a98297afd84e93f5befc8eda5f219c09e9792d65780b8af8949d25134
7
+ data.tar.gz: 9d7caf469da443e5be5b0aa963848cc0ce9f5eac7ae60542d67bdafee2841a7aa3bc8bfa0aca0f4f6422417e3144d300f5341ac38f39aaaf6052d4a8e0ff8eec
@@ -5,14 +5,18 @@ require_relative 'team_member_config'
5
5
  module Lhj
6
6
  # version info
7
7
  class AppVersionInfo
8
+
9
+ VERSION_REGEX = /^(?<begin>[^#]*MARKETING_VERSION\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/
10
+
8
11
  # @param [Symbol] env
9
12
  def initialize(env, build_number, work_path)
10
13
  @env = env
11
14
  @build_number = build_number
12
15
  @work_path = work_path
16
+ modify_code
17
+ end
13
18
 
14
- version_var_name = 'MARKETING_VERSION'
15
- @version_regex = /^(?<begin>[^#]*#{version_var_name}\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/i
19
+ def modify_code
16
20
  setup_config
17
21
  setup_shell_script
18
22
  setup_pod_script
@@ -66,25 +70,27 @@ module Lhj
66
70
  "#{build_app_version} (#{build_app_version_no}) (build: #{build_version})"
67
71
  end
68
72
 
69
- def build_app_version
70
- # app version '1.0.0'
73
+ def self.all_app_version(path)
71
74
  vers = []
72
- Dir.glob("#{@work_path}/*.xcodeproj/*.pbxproj").each do |file|
75
+ Dir.glob("#{path}/*.xcodeproj/*.pbxproj").each do |file|
73
76
  File.readlines(file).each do |l|
74
77
  next unless /MARKETING_VERSION/ =~ l
75
78
 
76
- version_match = @version_regex.match(l)
77
- major = version_match[:major].to_i
78
- minor = version_match[:minor].to_i || 0
79
- patch = version_match[:patch].to_i || 0
80
- vers << { value: version_match[:value], major: major, minor: minor, patch: patch }
79
+ vers << fetch_version(l)
81
80
  end
82
81
  end
83
- list = max_version(vers)
84
- list.last[:value]
82
+ sort_version_list(vers)
85
83
  end
86
84
 
87
- def max_version(list)
85
+ def self.fetch_version(line)
86
+ version_match = VERSION_REGEX.match(line)
87
+ major = version_match[:major].to_i
88
+ minor = version_match[:minor].to_i || 0
89
+ patch = version_match[:patch].to_i || 0
90
+ { value: version_match[:value], major: major, minor: minor, patch: patch }
91
+ end
92
+
93
+ def self.sort_version_list(list)
88
94
  list.sort do |a, b|
89
95
  ma = a[:major] <=> b[:major]
90
96
  ma = a[:minor] <=> b[:minor] if ma.zero?
@@ -93,6 +99,12 @@ module Lhj
93
99
  end
94
100
  end
95
101
 
102
+ def build_app_version
103
+ # app version '1.0.0'
104
+ vers = AppVersionInfo.all_app_version(@work_path)
105
+ vers.last[:value]
106
+ end
107
+
96
108
  def build_app_version_no
97
109
  # xcode build version
98
110
  # ${BUILD_NUMBER} of jenkins
@@ -76,6 +76,7 @@ module Lhj
76
76
  def upload_with_type(path, file)
77
77
  return unless @env == :release
78
78
  return unless /hai/ =~ path
79
+ return if @env == :release
79
80
 
80
81
  # step 1
81
82
  folder_path_dir = path
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.55'
4
+ VERSION = '0.2.57'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.55
4
+ version: 0.2.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj