vaultwarden-web/package_web_vault.sh

57 lines
1.2 KiB
Bash
Raw Normal View History

2018-12-13 16:09:59 +03:00
#!/bin/bash
set -o pipefail -o errexit
2018-12-13 16:09:59 +03:00
# Error handling
handle_error() {
read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." _
2018-12-13 16:09:59 +03:00
exit 1
}
trap 'handle_error $LINENO $?' ERR
# Ask for ref if not provided
2020-03-01 02:34:55 +03:00
if [[ -z "$VAULT_VERSION" ]]; then
read -rp "Input a git ref (commit hash, branch name, tag name, 'master'): " input
2020-03-01 02:34:55 +03:00
VAULT_VERSION="$input"
2018-12-13 16:09:59 +03:00
fi
VAULT_FOLDER=web-vault
OUTPUT_FOLDER=builds
2020-03-01 02:34:55 +03:00
OUTPUT_NAME="$OUTPUT_FOLDER/bw_web_$VAULT_VERSION.tar.gz"
mkdir -p "$OUTPUT_FOLDER"
2018-12-13 16:09:59 +03:00
# If this is the first time, clone the project
if [ ! -d "$VAULT_FOLDER" ]; then
git clone --recursive https://github.com/bitwarden/web.git "$VAULT_FOLDER"
2018-12-13 16:09:59 +03:00
fi
cd $VAULT_FOLDER
2018-12-13 16:09:59 +03:00
# Clean
git checkout -f
2018-12-13 16:09:59 +03:00
# Update branch
git fetch --tags
git pull origin master
# Checkput the branch we want
2020-03-01 02:34:55 +03:00
git checkout "$VAULT_VERSION"
git submodule update --recursive --init
2018-12-13 16:09:59 +03:00
## How to create patches
2019-04-03 16:44:07 +03:00
# git --no-pager diff --no-color --minimal > changes.patch
2018-12-13 16:09:59 +03:00
## How to apply patches
# git apply changes.patch
2020-03-01 02:34:55 +03:00
. ../apply_patches.sh
2018-12-13 16:09:59 +03:00
# Build
npm install
npm run dist
# Delete debugging map files, optional
#find build -name "*.map" -delete
2018-12-13 16:09:59 +03:00
# Prepare the final archives
mv build web-vault
tar -czvf "../$OUTPUT_NAME" web-vault --owner=0 --group=0
2020-03-14 16:05:25 +03:00
mv web-vault build