Skip to content

Commit 48f239e

Browse files
committed
Add bump version rake tasks
1 parent f1f04d6 commit 48f239e

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

rakelib/version-bump.rake

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
# frozen_string_literal: true
3+
4+
# -- Project version management
5+
6+
desc 'Bump build number'
7+
task :bump_build do
8+
sh "cd #{File.dirname(PROJECT_PATH)} && agvtool next-version -all"
9+
end
10+
11+
desc 'Bump patch version'
12+
task bump_patch: %i[has_current_version bump_build] do
13+
new_version = bump(version: current_version, option: :patch)
14+
update_version new_version
15+
end
16+
17+
desc 'Bump minor version'
18+
task bump_minor: %i[has_current_version bump_build] do
19+
new_version = bump(version: current_version, option: :minor)
20+
update_version new_version
21+
end
22+
23+
desc 'Bump major version'
24+
task bump_major: %i[has_current_version bump_build] do
25+
new_version = bump(version: current_version, option: :major)
26+
update_version new_version
27+
end
28+
29+
task :has_current_version do
30+
sh current_version_command
31+
end
32+
33+
task :set_version, [:version] do |_t, args|
34+
update_version args[:version]
35+
end
36+
37+
def update_version(version)
38+
sh "cd #{File.dirname(PROJECT_PATH)} && agvtool new-marketing-version #{version.to_s.strip}"
39+
end
40+
41+
def bump(version: '',
42+
option: '')
43+
version = version.split('.').map(&:to_i)
44+
case option
45+
when :patch
46+
version[2] = increase_number version[2]
47+
when :minor
48+
version.delete_at(2)
49+
version[1] = increase_number version[1]
50+
when :major
51+
version.delete_at(2)
52+
version[1] = 0
53+
version[0] = increase_number version[0]
54+
end
55+
version.join('.')
56+
end
57+
58+
def increase_number(option)
59+
option.nil? ? 1 : option + 1
60+
end
61+
62+
def full_version
63+
"#{current_version}-#{current_build}"
64+
end
65+
66+
def current_version
67+
`#{current_version_command}`.strip!
68+
end
69+
70+
def current_build
71+
`#{current_build_command}`.strip!
72+
end
73+
74+
def current_version_command
75+
"cd #{File.dirname(PROJECT_PATH)} && agvtool mvers -terse1"
76+
end
77+
78+
def current_build_command
79+
"cd #{File.dirname(PROJECT_PATH)} && agvtool vers -terse"
80+
end

swift-evolution.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@
832832
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
833833
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
834834
COPY_PHASE_STRIP = NO;
835+
CURRENT_PROJECT_VERSION = 1;
835836
DEBUG_INFORMATION_FORMAT = dwarf;
836837
ENABLE_STRICT_OBJC_MSGSEND = YES;
837838
ENABLE_TESTABILITY = YES;
@@ -855,6 +856,7 @@
855856
SDKROOT = iphoneos;
856857
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
857858
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
859+
VERSIONING_SYSTEM = "apple-generic";
858860
};
859861
name = Debug;
860862
};
@@ -881,6 +883,7 @@
881883
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
882884
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
883885
COPY_PHASE_STRIP = NO;
886+
CURRENT_PROJECT_VERSION = 1;
884887
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
885888
ENABLE_NS_ASSERTIONS = NO;
886889
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -897,6 +900,7 @@
897900
SDKROOT = iphoneos;
898901
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
899902
VALIDATE_PRODUCT = YES;
903+
VERSIONING_SYSTEM = "apple-generic";
900904
};
901905
name = Release;
902906
};

0 commit comments

Comments
 (0)