blob: a2aa230fe78006b555994c5291fa098f851b72b4 (
plain)
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
|
#!/bin/bash
PROJECT_NAME="0xtools"
if [ 0 -eq $# ]; then
echo ""
echo " Usage: ./release.sh tag_or_commitid [tag_or_commitid...]"
echo ""
exit 1
fi
for name in "$@"; do
target_type=$(git cat-file -t "${name}" 2>/dev/null)
if [[ -z "${target_type}" ]]; then
echo "${name} is invalid, ignored."
continue
fi
suffix=""
if expr "${target_type}" : "^commit" >/dev/null; then
suffix=$(git rev-parse --short=8 "${name}")
elif expr "${target_type}" : "^tag" >/dev/null; then
suffix="${name}"
else
echo "${name} is neither a commit nor a tag!"
continue
fi
target_name="${PROJECT_NAME}-${suffix}"
echo "archiving ${target_name}"
git archive -9 --format=tar.gz --prefix="${target_name}"/ "${name}" >"${target_name}".tar.gz
echo "finish ${target_name}"
done
|