forked from rmm5t/jquery-flexselect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (59 loc) · 2.17 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
67
68
69
70
require "bundler/setup"
require "rake/packagetask"
require "highline/import"
require "json"
verbose(true)
task :package => :version
package = Rake::PackageTask.new("jquery.flexselect", :noversion) do |p|
p.need_zip = true
p.package_files.include("*.js", "*.css", "*.html", "README.*")
end
jquery_package = JSON.parse(File.read("flexselect.jquery.json"))
task :version do
package.version = jquery_package["version"]
end
file package.package_dir_path do
input = "jquery.flexselect.js"
output = "#{package.package_dir_path}/#{input}"
rm_f output
sh("sed -e 's/%RELEASE_VERSION%/#{package.version}/g' -e 's/%RELEASE_DATE%/#{Date.today}/g' #{input} > #{output}")
end
desc "Publish a release to the wild"
task :publish do
sh "git checkout gh-pages"
sh "git merge master"
sh "git push -u origin gh-pages"
sh "git checkout master"
sh "git push"
sh "git push --tags"
end
desc "Construct a new release package, and optionally tag the repository"
task :release => [:rewrite_docs, :rewrite_bower, :commit, :repackage] do
sh("git tag -s 'v#{package.version}' -m 'Version #{package.version}'")
puts("\n *** Don't forget to push the zip file to a GitHub Release ***")
puts("\n *** Don't forget to `rake publish` ***")
end
desc "Rewrite the downlaod location in the docs"
task :rewrite_docs => :version do
docs = IO.read("index.html")
docs.sub!(/download_url =.*/, "download_url = \"https://github.com/rmm5t/jquery-flexselect/releases/download/v#{package.version}/jquery.flexselect-#{package.version}.zip\";")
File.open("index.html", "w") { |f| f.write docs }
end
desc "Rewrite the bower package manifest"
task :rewrite_bower => :version do
bower = {
"name" => "jquery-flexselect",
"version" => package.version,
"main" => ["jquery.flexselect.js", "flexselect.css"],
"ignore" => [ "test", "vendor" ],
"dependencies" => { "jquery" => ">=1.4" }
}
File.open("bower.json", "w") { |f| f.write(JSON.pretty_generate(bower)) }
end
desc "Stage and commit versioning changes"
task :commit => :version do
sh "git add index.html"
sh "git add flexselect.jquery.json"
sh "git add bower.json"
sh "git commit -m 'Bumped to v#{package.version}'"
end