-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build.sh: Make more robust & cleanup
- Loading branch information
Showing
1 changed file
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,55 @@ | ||
#!/bin/bash | ||
|
||
cwd=$(pwd) | ||
#!/usr/bin/env bash | ||
# Creates distribution archives. | ||
# Requires the binaries be already built (with make) | ||
# and moved to the stageing area. | ||
|
||
# Exit immediately on each error and unset variable; | ||
# see: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
#set -Eeuo pipefail | ||
set -Eeu | ||
|
||
argv0=$(echo "$0" | sed -e 's,\\,/,g') | ||
script_dir=$(dirname "$(readlink "$0" || echo "$argv0")") | ||
case "$(uname -s)" in | ||
*CYGWIN*) | ||
script_dir=$(cygpath -w "$script_dir") | ||
;; | ||
Linux) | ||
script_dir=$(dirname "$(readlink -f "$0" || echo "$argv0")") | ||
;; | ||
esac | ||
# shellcheck source=./ | ||
root="$script_dir" | ||
cwd="$(pwd)" | ||
|
||
BUILD_DIR=dist | ||
|
||
BUILD_DIR_STAGING=staging | ||
|
||
GIT_TAG_VERSION=`git describe --tag` | ||
GIT_TAG_VERSION="$(git describe --tag)" | ||
|
||
RELEASE_FILENAME_PREFIX=svg2shenzhen-extension | ||
# echo "$cwd/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
# echo "$root/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
RELEASE_FILENAME_BASE="${root:?}/$BUILD_DIR/${RELEASE_FILENAME_PREFIX}-${GIT_TAG_VERSION}" | ||
|
||
rm -fr $cwd/$BUILD_DIR/* | ||
rm -fr "${root:?}/$BUILD_DIR/"* | ||
|
||
mkdir -p "$cwd/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
mkdir -p "${root:?}/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
|
||
cp -r inkscape/* $cwd/$BUILD_DIR/$BUILD_DIR_STAGING | ||
cp -r inkscape/* "${root:?}/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
|
||
find $cwd/$BUILD_DIR/$BUILD_DIR_STAGING -name *.inx -type f -exec sed -i.bak s/SVGSZ_VER/${GIT_TAG_VERSION}/g '{}' \; | ||
find "${root:?}/$BUILD_DIR/$BUILD_DIR_STAGING" \ | ||
-name "*.inx" \ | ||
-type f \ | ||
-exec sed -i.bak "s/SVGSZ_VER/${GIT_TAG_VERSION}/g" '{}' \; | ||
|
||
rm -fr $cwd/$BUILD_DIR/$BUILD_DIR_STAGING/*.bak | ||
rm -fr "${root:?}/$BUILD_DIR/$BUILD_DIR_STAGING/"*.bak | ||
|
||
cd $cwd/$BUILD_DIR/$BUILD_DIR_STAGING | ||
cd "${root:?}/$BUILD_DIR/$BUILD_DIR_STAGING" | ||
|
||
tar -czvf $cwd/$BUILD_DIR/${RELEASE_FILENAME_PREFIX}-${GIT_TAG_VERSION}.tar.gz . | ||
zip -m -x .DS_Store -r $cwd/$BUILD_DIR/${RELEASE_FILENAME_PREFIX}-${GIT_TAG_VERSION}.zip . | ||
tar -czvf "${RELEASE_FILENAME_BASE}.tar.gz" . | ||
zip -m -x .DS_Store -r "${RELEASE_FILENAME_BASE}.zip" . | ||
|
||
cd $cwd | ||
cd "$cwd" | ||
|
||
ls dist | ||
ls "$BUILD_DIR" |