mirror of
https://github.com/dani-garcia/bw_web_builds.git
synced 2024-12-26 20:38:25 +03:00
commit
9648d630de
2 changed files with 31 additions and 32 deletions
12
package_all.sh
Normal file → Executable file
12
package_all.sh
Normal file → Executable file
|
@ -3,19 +3,19 @@
|
||||||
export UPLOAD_VAULT="n"
|
export UPLOAD_VAULT="n"
|
||||||
|
|
||||||
export WEB_REF="v2.5.0"
|
export WEB_REF="v2.5.0"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
||||||
export WEB_REF="v2.6.0"
|
export WEB_REF="v2.6.0"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
||||||
export WEB_REF="v2.6.1"
|
export WEB_REF="v2.6.1"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
||||||
export WEB_REF="v2.7.0"
|
export WEB_REF="v2.7.0"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
||||||
export WEB_REF="v2.7.1"
|
export WEB_REF="v2.7.1"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
||||||
export WEB_REF="v2.8.0"
|
export WEB_REF="v2.8.0"
|
||||||
sh package_web_vault.sh
|
bash package_web_vault.sh
|
||||||
|
|
51
package_web_vault.sh
Normal file → Executable file
51
package_web_vault.sh
Normal file → Executable file
|
@ -1,73 +1,72 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -o pipefail -o errexit
|
||||||
|
|
||||||
# Error handling
|
# Error handling
|
||||||
handle_error() {
|
handle_error() {
|
||||||
read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." key
|
read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." _
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
trap 'handle_error $LINENO $?' ERR
|
trap 'handle_error $LINENO $?' ERR
|
||||||
|
|
||||||
# Ask for ref if not provided
|
# Ask for ref if not provided
|
||||||
if [[ -z $WEB_REF ]]; then
|
if [[ -z "$WEB_REF" ]]; then
|
||||||
read -p "Input a git ref (commit hash, branch name, tag name, 'master'): " input
|
read -rp "Input a git ref (commit hash, branch name, tag name, 'master'): " input
|
||||||
WEB_REF=$input
|
WEB_REF="$input"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask if the result will be uploaded to github releases
|
# Ask if the result will be uploaded to github releases
|
||||||
if [[ -z $UPLOAD_VAULT ]]; then
|
if [[ -z $UPLOAD_VAULT ]]; then
|
||||||
read -p "Upload the result to GitHub Releases? (y/n): " input
|
read -rp "Upload the result to GitHub Releases? (y/n): " input
|
||||||
UPLOAD_VAULT=$input
|
UPLOAD_VAULT="$input"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If a patch was not provided, try to choose one
|
# If a patch was not provided, try to choose one
|
||||||
if [[ -z $PATCH_NAME ]]; then
|
if [[ -z $PATCH_NAME ]]; then
|
||||||
# If a patch with the same name as the ref exists, use it
|
# If a patch with the same name as the ref exists, use it
|
||||||
if [ -f patches/$WEB_REF.patch ]; then
|
if [ -f "patches/$WEB_REF.patch" ]; then
|
||||||
echo "Patch file found, using that"
|
echo "Patch file found, using that"
|
||||||
PATCH_NAME=$WEB_REF.patch
|
PATCH_NAME="$WEB_REF.patch"
|
||||||
else
|
else
|
||||||
echo "Patch file not found, using latest"
|
echo "Patch file not found, using latest"
|
||||||
# If not, use the latest one
|
# If not, use the latest one
|
||||||
PATCH_NAME=$(ls patches | sort -V | tail -n1)
|
PATCH_NAME="$(find patches -printf "%f\\n" | sort -V | tail -n1)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building git ref: " $WEB_REF
|
echo "Building git ref: $WEB_REF"
|
||||||
echo "Using patch: " $PATCH_NAME
|
echo "Using patch: $PATCH_NAME"
|
||||||
|
|
||||||
VAULT_FOLDER=web-vault
|
VAULT_FOLDER=web-vault
|
||||||
OUTPUT_FOLDER=builds
|
OUTPUT_FOLDER=builds
|
||||||
OUTPUT_NAME=$OUTPUT_FOLDER/bw_web_$WEB_REF.tar.gz
|
OUTPUT_NAME="$OUTPUT_FOLDER/bw_web_$WEB_REF.tar.gz"
|
||||||
OUTPUT_MSG=$OUTPUT_NAME.text
|
OUTPUT_MSG="$OUTPUT_NAME.text"
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_FOLDER"
|
||||||
|
|
||||||
# If this is the first time, clone the project
|
# If this is the first time, clone the project
|
||||||
if [ ! -d $VAULT_FOLDER ]; then
|
if [ ! -d "$VAULT_FOLDER" ]; then
|
||||||
git clone https://github.com/bitwarden/web.git $VAULT_FOLDER
|
git clone --recursive https://github.com/bitwarden/web.git "$VAULT_FOLDER"
|
||||||
mkdir OUTPUT_FOLDER
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $VAULT_FOLDER
|
cd $VAULT_FOLDER
|
||||||
|
|
||||||
# Clean
|
# Clean
|
||||||
git checkout .
|
git checkout -f
|
||||||
git submodule foreach --recursive git checkout .
|
|
||||||
|
|
||||||
# Update branch
|
# Update branch
|
||||||
git fetch --tags
|
git fetch --tags
|
||||||
git pull origin master
|
git pull origin master
|
||||||
|
|
||||||
# Checkput the branch we want
|
# Checkput the branch we want
|
||||||
git checkout $WEB_REF
|
git checkout "$WEB_REF"
|
||||||
|
git submodule update --recursive --init
|
||||||
# Update submodule
|
|
||||||
npm run sub:update
|
|
||||||
|
|
||||||
## How to create patches
|
## How to create patches
|
||||||
# git --no-pager diff --no-color --minimal > changes.patch
|
# git --no-pager diff --no-color --minimal > changes.patch
|
||||||
## How to apply patches
|
## How to apply patches
|
||||||
# git apply changes.patch
|
# git apply changes.patch
|
||||||
|
|
||||||
git apply ../patches/$PATCH_NAME
|
git apply "../patches/$PATCH_NAME"
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
npm install
|
npm install
|
||||||
|
@ -78,13 +77,13 @@ npm run dist
|
||||||
|
|
||||||
# Prepare the final archives
|
# Prepare the final archives
|
||||||
cd build
|
cd build
|
||||||
tar -czvf ../../$OUTPUT_NAME * --owner=0 --group=0
|
tar -czvf "../../$OUTPUT_NAME" ./* --owner=0 --group=0
|
||||||
|
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
if [[ $UPLOAD_VAULT =~ ^[Yy]$ ]]
|
if [[ $UPLOAD_VAULT =~ ^[Yy]$ ]]
|
||||||
then
|
then
|
||||||
sed "s/<VERSION>/$WEB_REF/g" release_template.md > $OUTPUT_MSG
|
sed "s/<VERSION>/$WEB_REF/g" release_template.md > "$OUTPUT_MSG"
|
||||||
# Install from here: https://hub.github.com/
|
# Install from here: https://hub.github.com/
|
||||||
hub release create -o -a $OUTPUT_NAME -F $OUTPUT_MSG $WEB_REF
|
hub release create -o -a "$OUTPUT_NAME" -F "$OUTPUT_MSG $WEB_REF"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue