-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgemreload
executable file
·34 lines (28 loc) · 1006 Bytes
/
gemreload
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
#!/bin/bash
if [[ -n "$1" && "$1" == "-h" || "$1" == "--help" ]]; then
echo -e "Builds and reinstalls the gem from the source in your current directory.\r\nUploads the gem to remote if the version has changed."
exit 0
fi
gem_name=`pwd | sed s#.*/##`
old_version=`gem list resque_empty_queue | sed "s#^.*(\([^)]*\))#\1#"`
new_version=`cat VERSION` || (echo 'Run this from the root of the gem project (expecting a VERSION file).' >&2; exit 1)
# Build the gem
echo "*** building gem '$gem_name' version '$new_version' (current version $old_version)"
rm -f *.gem
gem build "${gem_name}.gemspec"
gem_file=`ls *.gem`
# push it to RubyGems
if [[ "$new_version" != "$old_version" ]]; then
echo '*** Pushing to remote...'
gem push $gem_file
fi
# uninstall the gem
gem uninstall $gem_name
# reinstall the gem
if [[ "$new_version" != "$old_version" ]]; then
echo '*** Installing from remote...'
gem install $gem_name
else
echo '*** Installing from local gem file...'
gem install -l $gem_file
fi