-
Notifications
You must be signed in to change notification settings - Fork 26
/
update.sh
executable file
·137 lines (106 loc) · 3.73 KB
/
update.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
CURR_DIR=$(pwd)
# =========================== CHECK FORCE FLAG =================================
if [ "$1" == "--force" ]; then
FORCE=true
fi
# =========================== CURRENT VERSION INFO =============================
echo "--> Getting version numbers"
CURR_VERSION=$(curl -s https://jpadilla.github.io/redisapp/ | grep -o '<div class="current-version">v.*' | grep -o '[0-9]*\.[0-9]*\.[0-9]*-build\.[0-9]*')
CURR_REDIS=$(echo $CURR_VERSION | grep -o '^[0-9]*\.[0-9]*\.[0-9]*')
CURR_BUILD=$(echo $CURR_VERSION | grep -o '[0-9]*$')
echo " -- Current Redis.app version: $CURR_BUILD"
# =========================== LATEST VERSION INFO ==============================
# Get redis latest stable release version
VERSION=$(curl -s http://download.redis.io/redis-stable/00-RELEASENOTES | grep -o 'Redis .* Released' | head -n 1 | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
echo "--> Current redis version: $VERSION"
# =========================== COMPARE VERSIONS =================================
if [ "$FORCE" != true ] && [ "$CURR_REDIS" == "$VERSION" ]; then
echo " -- No need to update :)"
echo "==> Done!"
exit 0
fi
# =========================== DOWNLOAD =========================================
# Create download url
DOWNLOAD_URL="http://download.redis.io/releases/redis-$VERSION.tar.gz"
# Download latest stable release version
echo "--> Downloading: $DOWNLOAD_URL"
curl -o /tmp/redis.tar.gz $DOWNLOAD_URL
# Clean old redis dir
VENDOR_DIR="$(pwd)/Vendor/redis"
echo "--> Cleaning directory $VENDOR_DIR"
rm -rf $VENDOR_DIR
# Create dir
echo "--> Creating directory $VENDOR_DIR"
mkdir -p $VENDOR_DIR
# Extract
echo "--> Unzipping..."
tar xvzf /tmp/redis.tar.gz -C /tmp
# Compile
echo "--> Compiling..."
cd /tmp/redis-*/
make install PREFIX="../"
cd $CURR_DIR
# move files
echo "--> Moving files to $VENDOR_DIR"
mv /tmp/redis-*/* $VENDOR_DIR
# cleanup
echo "--> Removing /tmp/redis.tar.gz"
rm /tmp/redis.tar.gz
echo "--> Removing /tmp/redis-*"
rm -r /tmp/redis-*
echo "--> Download completed!"
# =========================== BUILD ============================================
echo '--> Building'
# Use sequential build numbers
if [ "$FORCE" ]; then
NEW_BUILD=$((CURR_BUILD + 1))
else
NEW_BUILD=1
fi
export RELEASE_VERSION="${VERSION}-build.${NEW_BUILD}"
echo " -- Update Info.plist version ${RELEASE_VERSION}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${RELEASE_VERSION}" Redis/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${RELEASE_VERSION}" Redis/Info.plist
echo " -- Clean build folder"
rm -rf build/
echo " -- Build with defaults"
xcodebuild
echo " -- Build completed!"
# =========================== RELEASE ==========================================
echo '--> Release'
echo " -- Zip"
cd build/Release
zip -r -y "$CURR_DIR/Redis.zip" Redis.app
cd ../../
# Get zip file size
FILE_SIZE=$(du "$CURR_DIR/Redis.zip" | cut -f1)
echo " -- Create AppCast post"
rm -rf ./_posts/release
mkdir -p ./_posts/release/
echo "---
version: $RELEASE_VERSION
redis_version: $VERSION
package_url: https://github.com/jpadilla/redisapp/releases/download/$RELEASE_VERSION/Redis.zip
package_length: $FILE_SIZE
category: release
---
- Updates redis to $VERSION
" > ./_posts/release/$(date +"%Y-%m-%d")-${RELEASE_VERSION}.md
# =========================== PUBLISH ==========================================
echo ""
echo "================== Next steps =================="
echo ""
echo "git commit -am 'Release $RELEASE_VERSION'"
echo "git tag $RELEASE_VERSION"
echo "git push origin --tags"
echo ""
echo "Upload Redis.zip to GitHub"
echo "https://github.com/jpadilla/redisapp/releases/tag/$RELEASE_VERSION"
echo ""
echo "git co gh-pages"
echo "git add ."
echo "git commit -am 'Release $RELEASE_VERSION'"
echo "git push origin gh-pages"
echo ""
echo "==> Done!"