forked from igorescobar/jQuery-Mask-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.rb
82 lines (66 loc) · 2.51 KB
/
deploy.rb
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
71
72
73
74
75
76
77
78
79
80
81
82
require 'rubygems'
require 'zlib'
JMASK_FILE = 'src/jquery.mask.js'
JMASK_MIN_FILE = 'dist/jquery.mask.min.js'
GHPAGES_JMASK_MIN_FILE = 'js/jquery.mask.min.js'
JMASK_GZIP_FILE = 'dist/jquery.mask.min.js.gz'
JMASK_VERSION = `stepup version --next-release`.delete("\n")
BOWER_MANIFEST_FILE = 'bower.json'
NPM_MANIFEST_FILE = 'package.json'
COMPONENT_MANIFEST_FILE = 'component.json'
abort("No notes, do deal.") if JMASK_VERSION.empty?
puts '# PUTTING NEW VERSION INSIDE OF JQUERY MASK FILE'
unversioned_jmask_file = File.open(JMASK_FILE, 'rb') { |file| file.read }
File.open(JMASK_FILE, 'w') do |file|
file.write(unversioned_jmask_file.gsub(/\* @version: (v[0-9.+]+)/, "\* @version: #{JMASK_VERSION}"))
end
puts '# COPYING NEW JMASK FILE TO DIST/'
`yes | cp #{JMASK_FILE} dist/`
[BOWER_MANIFEST_FILE, NPM_MANIFEST_FILE, COMPONENT_MANIFEST_FILE].each { |manifest_name|
puts "# UPGRADING #{manifest_name} "
manifest_file = File.open(manifest_name, 'rb') { |file| file.read }
File.open(manifest_name, 'w') do |file|
file.write(manifest_file.gsub(/"version": "([0-9.+]+)"/, "\"version\": \"#{JMASK_VERSION.gsub("v", "")}\""))
end
}
puts '# GENERATING MIN FILE'
jquery_mask_min_file = nil
File.open(JMASK_FILE, 'r') do |file|
minFile = File.open(JMASK_MIN_FILE, 'w')
minFile.puts("// jQuery Mask Plugin #{JMASK_VERSION}")
minFile.puts("// github.com/igorescobar/jQuery-Mask-Plugin")
jquery_mask_min_file = `java -jar ../clojure-compiler/compiler.jar --js src/jquery.mask.js --charset UTF-8`
minFile.puts(jquery_mask_min_file)
minFile.close
end
puts '# GENERATING GZIP FILE'
File.open(JMASK_GZIP_FILE, 'w') do |f|
minFile = File.open(JMASK_MIN_FILE, 'r').read
gz = Zlib::GzipWriter.new(f)
gz.write minFile
gz.close
end
puts '# GENERATING A NEW COMMIT WITH VERSIONED FILEs'
`git commit -am 'generating jquery mask files #{JMASK_VERSION}'`
puts '# PUSHING CHANGES TO REMOTE'
`git pull --rebase && git push`
puts '# CREATING NEW VERSION'
`stepup version create --no-editor`
puts '# UPGRATING CHANGELOG'
`stepup changelog --format=wiki > CHANGELOG.md`
`git commit -am "upgrading changelog"`
`git push`
puts '# UPGRADING gh-pages'
`git checkout gh-pages`
`git pull origin gh-pages`
minFile = File.open(GHPAGES_JMASK_MIN_FILE, 'w')
minFile.puts("// jQuery Mask Plugin #{JMASK_VERSION}")
minFile.puts("// github.com/igorescobar/jQuery-Mask-Plugin")
minFile.puts(jquery_mask_min_file)
minFile.close
`git commit -am "upgrading plugin file"`
`git push`
`git checkout master`
puts '# PUBLISHING NPM PACKAGE'
`npm publish`
puts '# DONE!'