forked from stencilproject/Stencil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·52 lines (41 loc) · 1.63 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
#!/usr/bin/rake
unless defined?(Bundler)
puts 'Please use bundle exec to run the rake command'
exit 1
end
require 'English'
## [ Constants ] ##############################################################
POD_NAME = 'Stencil'
MIN_XCODE_VERSION = 13.0
BUILD_DIR = File.absolute_path('./.build')
## [ Build Tasks ] ############################################################
namespace :files do
desc 'Update all files containing a version'
task :update, [:version] do |_, args|
version = args[:version]
Utils.print_header "Updating files for version #{version}"
podspec = Utils.podspec(POD_NAME)
podspec['version'] = version
podspec['source']['tag'] = version
File.write("#{POD_NAME}.podspec.json", JSON.pretty_generate(podspec) + "\n")
replace('CHANGELOG.md', '## Master' => "\#\# #{version}")
replace("docs/conf.py",
/^version = .*/ => %Q(version = '#{version}'),
/^release = .*/ => %Q(release = '#{version}')
)
docs_package = Utils.first_match_in_file('docs/installation.rst', /\.package\(url: .+ from: "(.+)"/, 1)
replace("docs/installation.rst",
/\.package\(url: .+, from: "(.+)"/ => %Q(.package\(url: "https://github.com/stencilproject/Stencil.git", from: "#{version}"),
/pod 'Stencil', '.*'/ => %Q(pod 'Stencil', '~> #{version}'),
/github "stencilproject\/Stencil" ~> .*/ => %Q(github "stencilproject/Stencil" ~> #{version})
)
end
def replace(file, replacements)
content = File.read(file)
replacements.each do |match, replacement|
content.gsub!(match, replacement)
end
File.write(file, content)
end
end
task :default => 'release:new'