-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-release
More file actions
executable file
·43 lines (31 loc) · 1.06 KB
/
make-release
File metadata and controls
executable file
·43 lines (31 loc) · 1.06 KB
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
#! /usr/bin/env bash
set -euo pipefail
readonly BUILD_DIR="/tmp/shell-tea-timer.build"
readonly TARGET_DIR="${HOME}/Downloads/"
readonly UNDEF_VALUE="undefined"
readonly tag="$(git describe --tags)"
readonly gendatetime="$(date +'%d.%m.%Y %H:%M:%S')"
function replace_placeholders() {
local relative_filepath="${1}"
cat "${relative_filepath}" \
| sed "s/{{{version}}}/${tag}/" \
| sed "s/{{{generated_on}}}/${gendatetime}/" \
> "${BUILD_DIR}/${relative_filepath}"
}
if [[ "${tag}" == "${UNDEF_VALUE}" ]]; then
>&2 echo
>&2 echo "You have to be on tagged commit!"
exit 1
fi
if [[ -d "${BUILD_DIR}" ]]; then
echo -n "About to remove build dir [${BUILD_DIR}]. Continue [enter/ctrl+c]? "
read -r answer
command rm -rf "${BUILD_DIR}"
fi
files=( "shell-tea-timer" "conf" "libs" "vendor" "README.md" "LICENSE" )
mkdir "${BUILD_DIR}"
cp -r "${files[@]}" "${BUILD_DIR}/"
replace_placeholders "shell-tea-timer"
replace_placeholders "libs/flow"
cd "${BUILD_DIR}"
tar -czvf "${TARGET_DIR}/shell-tea-timer.${tag}.tar.gz" "${files[@]}"