-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
66 lines (50 loc) · 1.21 KB
/
Rakefile
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
55
56
57
58
59
60
61
62
63
64
65
66
help = <<ENDHELP
This Rakefile specifies various development and maintainence tasks for appicon-generator.
To make a release of version 0.99:
rake "release[0.99]"
ENDHELP
# Constants
VERSION_SWIFT = "./Sources/AppIconGeneratorCore/Version.swift"
DOT_VERSION = "./.version"
# Tasks
task default: [:info]
task :info do
puts help
end
task :release, [:version] do |t, args|
unless git_is_clean? || should_force?
abort("Please commit changes to git first.")
end
version = args.version
puts "Setting version number #{version}"
write_version_swift(version)
write_dot_version(version)
system('git', 'commit', '-a', '-m', "Release #{version}")
system('git', 'tag', '-a', version, '-m', version)
end
# Helpers
def write_version_swift(version)
File.write(VERSION_SWIFT, <<EOF)
//
// This file is generated by a rake script.
//
public extension AppIconGenerator {
static var version: String {
return "#{version}"
}
}
EOF
end
def write_dot_version(version)
File.write(DOT_VERSION, "#{version}\n")
end
def abort(message)
puts message
exit 1
end
def git_is_clean?
`git status --porcelain`.empty?
end
def should_force?
ENV["FORCE"] == "yes"
end