Skip to content

Commit

Permalink
Add new arg for upfrom version in release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Apr 5, 2024
1 parent b64d017 commit 7adf7be
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
19 changes: 16 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ UPGRADE=0
PREPARE=0
SERVICE_CREATION=0
SUFFIX=""
UPFROM=latest

usage() {
echo "Usage:"
Expand All @@ -18,18 +19,21 @@ usage() {
echo " " release.sh -p "Prepare the release"
echo " " release.sh -u "Upgrade the release"
echo " " release.sh -s "Create a systemd service"
echo " " release.sh -v "Specifiy the version to up from, works only with -p"
echo " " release.sh -h "Print the help usage"
echo ""
}

while getopts :suphn: option
while getopts :suphn:v: option
do
case "${option}"
in
u) UPGRADE=1;;
p) PREPARE=1;;
n) SUFFIX=-${OPTARG};;
s) SERVICE_CREATION=1;;
v)
UPFROM=${OPTARG};;
h)
usage
exit 0
Expand All @@ -42,6 +46,11 @@ do
done
shift $((OPTIND -1))

if [[ $UPFROM != "latest" && $PREPARE == 0 ]]; then
usage
exit 1
fi

source ~/.profile

if [[ $SUFFIX == "" ]]
Expand Down Expand Up @@ -112,8 +121,12 @@ mkdir -p $INSTALL_DIR
if [[ $PREPARE == 1 ]]
then
# Build upgrade releases
echo "Build the upgrade release"
MIX_ENV=prod mix distillery.release --upgrade
echo "Build the upgrade release from $UPFROM version"
if [[ $UPFROM == "latest" ]]; then
MIX_ENV=prod mix distillery.release --upgrade
else
MIX_ENV=prod mix distillery.release --upgrade --upfrom $UPFROM
fi

echo "Copy upgraded release into ${INSTALL_DIR}/releases/${VERSION}"
mkdir -p $INSTALL_DIR/releases/$VERSION
Expand Down
17 changes: 15 additions & 2 deletions scripts/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ UPGRADE=0
INSTALL=0
PREPARE=0
NB_OF_RELEASES=0
UPFROM=latest
export MIX_ENV=dev

usage() {
Expand All @@ -20,11 +21,12 @@ usage() {
echo " " release.sh -p " Prepare the release for hot reload"
echo " " release.sh -u " Upgrade the release"
echo " " release.sh -n " Set the number of node to apply the command"
echo " " release.sh -v " Specifiy the version to up from, works only with -p"
echo " " release.sh -h " Print the help usage"
echo ""
}

while getopts ":uiphn:" option; do
while getopts ":uiphn:v:" option; do
case "${option}" in
u) UPGRADE=1 ;;
p) PREPARE=1 ;;
Expand All @@ -37,6 +39,8 @@ while getopts ":uiphn:" option; do
exit 1
fi
;;
v)
UPFROM=${OPTARG};;
h)
usage
exit 0
Expand All @@ -53,6 +57,11 @@ if [[ $NB_OF_RELEASES = 0 ]]; then
NB_OF_RELEASES=2
fi

if [[ $UPFROM != "latest" && $PREPARE == 0 ]]; then
usage
exit 1
fi

# For every commands:
cd $SCRIPT_DIR/..

Expand Down Expand Up @@ -111,7 +120,11 @@ elif [ $PREPARE == 1 ]; then

build_deps

mix distillery.release --upgrade
if [[ $UPFROM == "latest" ]]; then
mix distillery.release --upgrade
else
mix distillery.release --upgrade --upfrom $UPFROM
fi

# cp the .tar.gz for distillery
echo "Copy release on $NB_OF_RELEASES release dir"
Expand Down

0 comments on commit 7adf7be

Please sign in to comment.