forked from seanbehan/videojs_rails
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
49 lines (40 loc) · 1.71 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
require 'bundler/gem_tasks'
# Build the version of video.js and tag us to match
VIDEO_JS_RAILS_HOME = File.expand_path(File.dirname(__FILE__))
VIDEO_JS_HOME = File.expand_path('tmp', VIDEO_JS_RAILS_HOME)
VIDEO_JS_RAKE_USAGE = "Usage: rake videojs:update VERSION=5.11.6"
namespace :videojs do
task :update => [:build, :commit]
task :build do
version = ENV['VERSION'] or abort VIDEO_JS_RAKE_USAGE
FileUtils.mkdir_p(VIDEO_JS_HOME)
Dir.chdir(VIDEO_JS_HOME) do
dist_dir = "#{VIDEO_JS_HOME}/video-js-#{version}"
unless Dir.exist?(dist_dir)
puts "* Downloading video.js #{version}"
sh "curl -s -L -O https://github.com/videojs/video.js/releases/download/v#{version}/video-js-#{version}.zip"
sh "unzip video-js-#{version}.zip -d video-js-#{version}"
end
# Copy files into our Rails structure
puts
puts "* Copying files to vendor/assets"
sh "cp #{dist_dir}/font/* #{VIDEO_JS_RAILS_HOME}/vendor/assets/fonts/"
sh "cp #{dist_dir}/video-js.css #{VIDEO_JS_RAILS_HOME}/vendor/assets/stylesheets/"
sh "cp #{dist_dir}/video.js #{VIDEO_JS_RAILS_HOME}/vendor/assets/javascripts/"
end
end
task :commit do
version = ENV['VERSION'] or abort VIDEO_JS_RAKE_USAGE
# Update the gem version
version_file = "#{VIDEO_JS_RAILS_HOME}/lib/videojs_rails/version.rb"
lines = File.read(version_file)
File.open(version_file, 'w') do |out|
puts "* Setting gem version = #{version}"
out << lines.sub(/(VERSION\s*=\s*)\S+/, "\\1'#{version}'")
end
sh "git add ."
sh "git commit -m 'Update to video.js v#{version}'"
sh "git tag -a v#{version} -m \"v#{version}\""
puts "* Done. Now run 'rake release' to push to rubygems."
end
end