-
Notifications
You must be signed in to change notification settings - Fork 497
/
dist_blade
executable file
·63 lines (51 loc) · 1.5 KB
/
dist_blade
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
#!/bin/bash
# make_blade_zip
# AUTHOR: Michael
# DATE: Dec 17 2011
# REV: 1.1.A (Valid are A, B, D, T and P)
# (For Alpha, Beta, Dev, Test and Production)
#
# PLATFORM: Linux
# PURPOSE : This script is used to make blade sources to be a zip ball.
# REV LIST:
# DATE: Dec 17 2011
# BY : Michaelpeng
# MODIFICATION: Created
LC_ALL=C
function blade_version() {
local branch
local version
local log
branch=$(git branch | grep '^\*')
if echo "$branch" | egrep 'detached (at|from)' > /dev/null; then
# Extract tag name
version=$(echo "$branch" | sed -E -n 's/\* \(.* detached (at|from) (.*)\)/\2/p')
else
version=$(echo "$branch" | sed -n 's/\* \(.*\)$/("\1" branch)/p')
fi
# get last commit brief
log=$(git log -1 --format="%ad %h, by %cn" --date=short)
# Examples:
# 2.0.0, 2019-03-16 3b2ad0d, by CHEN Feng
# ("version" branch), 2019-03-16 3b2ad0d, by CHEN Feng
echo "$version, $log"
}
# For debug
# blade_version; exit
function make_blade_zip() {
local version
version=$(blade_version)
blade_dir=$(cd $(dirname $0) && pwd)
cd $blade_dir
echo "Blade directory: ${blade_dir}"
src_dir='./src'
dist_file_path=${blade_dir}'/blade.zip'
cd $src_dir
echo "VERSION = r'''$version'''" > blade/blade_version.py
zip blade.zip __main__.py blade/*.py
rm blade/blade_version.py
mv ./blade.zip ${dist_file_path}
cd $blade_dir
echo 'Done'
}
make_blade_zip