diff --git a/app/Commands/Env/EnvBackupCommand.php b/app/Commands/Env/EnvBackupCommand.php index c847320..cac9376 100644 --- a/app/Commands/Env/EnvBackupCommand.php +++ b/app/Commands/Env/EnvBackupCommand.php @@ -31,7 +31,7 @@ class EnvBackupCommand extends Command { $this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath())); - Storage::put($this->argument('file'), Storage::get('.env')); + Storage::put(sprintf('backups/%s', $this->argument('file')), Storage::get('.env')); $this->info('The environment file was successfully backed up.'); diff --git a/app/Commands/Env/EnvRestoreCommand.php b/app/Commands/Env/EnvRestoreCommand.php index 1525efc..28fd35d 100644 --- a/app/Commands/Env/EnvRestoreCommand.php +++ b/app/Commands/Env/EnvRestoreCommand.php @@ -31,7 +31,7 @@ class EnvRestoreCommand extends Command { $this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath())); - Storage::put('.env', Storage::get($this->argument('file'))); + Storage::put('.env', Storage::get(sprintf('backups/%s', $this->argument('file')))); $this->info('The environment file was successfully restored.'); diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..f56ef00 --- /dev/null +++ b/build.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +# Accepts a version string and prints it incremented by one. +# Usage: increment_version [] [] +increment_version() { + local usage=" USAGE: $FUNCNAME [-l] [-t] [] [] + -l : remove leading zeros + -t : drop trailing zeros + : The version string. + : Optional. The position (starting with one) of the number + within to increment. If the position does not + exist, it will be created. Defaults to last position. + : The leftmost position that can be incremented. If does not + exist, position will be created. This right-padding will + occur even to right of , unless passed the -t flag." + + # Get flags. + local flag_remove_leading_zeros=0 + local flag_drop_trailing_zeros=0 + while [ "${1:0:1}" == "-" ]; do + if [ "$1" == "--" ]; then shift; break + elif [ "$1" == "-l" ]; then flag_remove_leading_zeros=1 + elif [ "$1" == "-t" ]; then flag_drop_trailing_zeros=1 + else echo -e "Invalid flag: ${1}\n$usage"; return 1; fi + shift; done + + # Get arguments. + if [ ${#@} -lt 1 ]; then echo "$usage"; return 1; fi + local v="${1}" # version string + local targetPos=${2-last} # target position + local minPos=${3-${2-0}} # minimum position + + # Split version string into array using its periods. + local IFSbak; IFSbak=IFS; IFS='.' # IFS restored at end of func to + read -ra v <<< "$v" # avoid breaking other scripts. + + # Determine target position. + if [ "${targetPos}" == "last" ]; then + if [ "${minPos}" == "last" ]; then minPos=0; fi + targetPos=$((${#v[@]}>${minPos}?${#v[@]}:$minPos)); fi + if [[ ! ${targetPos} -gt 0 ]]; then + echo -e "Invalid position: '$targetPos'\n$usage"; return 1; fi + (( targetPos-- )) || true # offset to match array index + + # Make sure minPosition exists. + while [ ${#v[@]} -lt ${minPos} ]; do v+=("0"); done; + + # Increment target position. + v[$targetPos]=`printf %0${#v[$targetPos]}d $((10#${v[$targetPos]}+1))`; + + # Remove leading zeros, if -l flag passed. + if [ $flag_remove_leading_zeros == 1 ]; then + for (( pos=0; $pos<${#v[@]}; pos++ )); do + v[$pos]=$((${v[$pos]}*1)); done; fi + + # If targetPosition was not at end of array, reset following positions to + # zero (or remove them if -t flag was passed). + if [[ ${flag_drop_trailing_zeros} -eq "1" ]]; then + for (( p=$((${#v[@]}-1)); $p>$targetPos; p-- )); do unset v[$p]; done + else for (( p=$((${#v[@]}-1)); $p>$targetPos; p-- )); do v[$p]=0; done; fi + + echo "${v[*]}" + IFS=IFSbak + return 0 +} + +RELEASED_BUILD_VERSION=$(git describe --abbrev=0 --tags) +BUILD_VERSION=$(increment_version $RELEASED_BUILD_VERSION) + +echo "Building bunny-cli for version $BUILD_VERSION (previous version was $RELEASED_BUILD_VERSION)..." + +$PWD/bunny app:build --build-version "$BUILD_VERSION" diff --git a/builds/bunny b/builds/bunny index 7c4d717..806d447 100755 Binary files a/builds/bunny and b/builds/bunny differ diff --git a/config/app.php b/config/app.php index f1fe664..faad04a 100644 --- a/config/app.php +++ b/config/app.php @@ -13,7 +13,7 @@ return [ | */ - 'name' => 'Bunny.net', + 'name' => 'bunny.net', /* |--------------------------------------------------------------------------