1
- #! /bin/bash
1
+ #! /usr/bin/env bash
2
+ # Creates distribution archives.
3
+ # Requires the binaries be already built (with make)
4
+ # and moved to the stageing area.
2
5
3
- cwd=$( pwd)
6
+ # Exit immediately on each error and unset variable;
7
+ # see: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
8
+ # set -Eeuo pipefail
9
+ set -Eeu
10
+
11
+ # shellcheck source=./
12
+ script_dir=$( dirname " $( readlink -f " ${BASH_SOURCE[0]} " ) " )
13
+ root=" $script_dir "
14
+ cwd=" $( pwd) "
4
15
5
16
BUILD_DIR=dist
6
17
7
18
BUILD_DIR_STAGING=staging
8
19
9
- GIT_TAG_VERSION=` git describe --tag`
20
+ GIT_TAG_VERSION=" $( git describe --tag) "
10
21
11
22
RELEASE_FILENAME_PREFIX=svg2shenzhen-extension
12
- # echo "$cwd/$BUILD_DIR/$BUILD_DIR_STAGING"
23
+ # echo "$root/$BUILD_DIR/$BUILD_DIR_STAGING"
24
+ RELEASE_FILENAME_BASE=" ${root:? } /$BUILD_DIR /${RELEASE_FILENAME_PREFIX} -${GIT_TAG_VERSION} "
13
25
14
- rm -fr $cwd /$BUILD_DIR /*
26
+ rm -fr " ${root :? } /$BUILD_DIR /" *
15
27
16
- mkdir -p " $cwd /$BUILD_DIR /$BUILD_DIR_STAGING "
28
+ mkdir -p " ${root :? } /$BUILD_DIR /$BUILD_DIR_STAGING "
17
29
18
- cp -r inkscape/* $cwd /$BUILD_DIR /$BUILD_DIR_STAGING
30
+ cp -r inkscape/* " ${root :? } /$BUILD_DIR /$BUILD_DIR_STAGING "
19
31
20
- find $cwd /$BUILD_DIR /$BUILD_DIR_STAGING -name * .inx -type f -exec sed -i.bak s/SVGSZ_VER/${GIT_TAG_VERSION} /g ' {}' \;
32
+ find " ${root:? } /$BUILD_DIR /$BUILD_DIR_STAGING " \
33
+ -name " *.inx" \
34
+ -type f \
35
+ -exec sed -i.bak " s/SVGSZ_VER/${GIT_TAG_VERSION} /g" ' {}' \;
21
36
22
- rm -fr $cwd /$BUILD_DIR /$BUILD_DIR_STAGING /* .bak
37
+ rm -fr " ${root :? } /$BUILD_DIR /$BUILD_DIR_STAGING /" * .bak
23
38
24
- cd $cwd /$BUILD_DIR /$BUILD_DIR_STAGING
39
+ cd " ${root :? } /$BUILD_DIR /$BUILD_DIR_STAGING "
25
40
26
- tar -czvf $cwd / $BUILD_DIR / ${RELEASE_FILENAME_PREFIX} - ${GIT_TAG_VERSION} .tar.gz .
27
- zip -m -x .DS_Store -r $cwd / $BUILD_DIR / ${RELEASE_FILENAME_PREFIX} - ${GIT_TAG_VERSION} .zip .
41
+ tar -czvf " ${RELEASE_FILENAME_BASE} .tar.gz" .
42
+ zip -m -x .DS_Store -r " ${RELEASE_FILENAME_BASE} .zip" .
28
43
29
- cd $cwd
44
+ cd " $cwd "
30
45
31
- ls dist
46
+ ls " $BUILD_DIR "
0 commit comments