-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy
57 lines (41 loc) · 1.13 KB
/
deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
def execute(cmd)
puts "\n***************************************************************************\n"
puts "$ #{cmd}"
system(cmd)
end
def version_file_path
'./String Utility.sketchplugin/Contents/Sketch/manifest.json'
end
def version_file
@version_file ||= File.read(version_file_path)
end
def version
@version ||= version_file.match(/"version"\s*:\s*"([^"]*)"/)[1]
end
def increment_version
parts = version.split('.')
parts[2] = (parts[2].to_i + 1).to_s
new_version = parts.join('.')
version_file.gsub!(version, new_version)
File.open(version_file_path, 'w') do |file|
file.write(version_file)
end
@version_file = nil
@version = nil
end
puts "\nDeploying String Utility.sketchplugin (#{version})..."
if ARGV.include?('release')
execute('git checkout master')
execute('git merge develop')
execute('git push')
end
if ARGV.include?('release')
execute("git tag #{version}")
execute('git push --tags')
execute('git checkout develop')
increment_version
execute("git add '#{version_file_path}'")
execute("git commit -m 'Updated version to #{version}'")
execute('git push')
end