-
Notifications
You must be signed in to change notification settings - Fork 1
/
rakefile
91 lines (69 loc) · 2.01 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
require 'io/console'
require 'json'
desc "Pushes changes to npm and GitHub."
task :release do
# Check node version
puts "> NODE VERSION CHECK..."
version = (runOrFail "node --version").delete!("\n")
if version != "v16.6.1"
raise "Node version is #{version} but must be v16.6.1"
end
# Make sure you're on master
puts "> RUNNING BRANCH CHECK..."
branch = runOrFail("git branch | grep \\* | cut -d ' ' -f2").delete!("\n")
if branch != "master"
raise "You're on #{branch}, not master."
end
# In sync with origin
puts "> RUNNING SYNC CHECK..."
runOrFail "git fetch origin master"
commitsOff = (runOrFail "git rev-list HEAD...origin/master --count").delete!("\n").to_i
if commitsOff < 0 then
raise "You're not synced with the origin."
end
puts "> RUNNING COVERAGE..."
runOrFail "npm run coverage"
puts "> RUNNING TEST..."
runOrFail "npm run test"
puts "> RUNNING PATCH BUMP..."
runOrFail "npm --no-git-tag-version version patch"
puts "> RUNNING BUILD..."
runOrFail "npm run build"
puts "> RUNNING GET VERSION..."
packageFile = File.open "./package.json"
packageData = JSON.load packageFile
version = packageData["version"]
puts "> RUNNING COMMIT..."
runOrFail "NO_BUMP=true git commit -am \"Release #{version}\""
puts "> RUNNING TAG..."
tag = "v#{version}"
runOrFail "git tag #{tag}"
puts "> RUNNING PUSH GitHub..."
runOrFail "git push origin master"
puts "> RUNNING PUSH TAG..."
runOrFail "git push --tags"
puts "> RUNNING NPM PUBLISH..."
runOrFail "npm publish"
puts ""
puts "Version #{version} is live:"
puts " • https://github.com/bendytree/node-itsa"
puts " • http://npmjs.com/package/itsa"
puts ""
end
task :bumppatch do
if ENV['NO_BUMP'] == "true"
exit 0
end
runOrFail "npm --no-git-tag-version version patch"
runOrFail "git add package.json package-lock.json"
exit 0
end
def runOrFail (cmd)
puts "> " + cmd
result = `#{cmd}`
puts result
unless $?.exitstatus == 0
exit $?.exitstatus
end
result
end