Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: version number before backend deployment (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
maghirardelli authored Sep 27, 2021
1 parent 5887170 commit 6d545dd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion scripts/check-and-add-beta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
# Create ed file
echo "5i
## Beta
[This release is in beta. Click here to see changes since ${latestReleaseVersion}.](https://github.com/maghirardelli/service-workbench-on-aws-github-actions/compare/v${latestReleaseVersion}...mainline)
[This release is in beta. Click here to see changes since ${latestReleaseVersion}.](https://github.com/awslabs/service-workbench-on-aws/compare/v${latestReleaseVersion}...mainline)
.
w
Expand Down
99 changes: 50 additions & 49 deletions scripts/environment-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,7 @@ pushd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null
[[ $UTIL_SOURCED != yes && -f ./util.sh ]] && source ./util.sh
popd > /dev/null

# Install
install_dependencies "$@"

function disableStats {
COMPONENT_DIR=$1
pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
# Disable serverless stats (only strictly needs to be done one time)
$EXEC sls slstats --disable -s "$STAGE"
popd > /dev/null
}

function componentDeploy {
COMPONENT_DIR=$1
COMPONENT_NAME=$2

pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
printf "\nDeploying component: %s ...\n\n" "$COMPONENT_NAME"
$EXEC sls deploy -s "$STAGE"
printf "\nDeployed component: %s successfully \n\n" "$COMPONENT_NAME"
popd > /dev/null
}

function goComponentDeploy() {
COMPONENT_DIR=$1
COMPONENT_NAME=$2

pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
printf "\nDeploying Go component: %s ...\n\n" "$COMPONENT_NAME"
$EXEC sls deploy-go -s "$STAGE"
printf "\nDeployed Go component: %s successfully \n\n" "$COMPONENT_NAME"
popd > /dev/null
}

disableStats "infrastructure"
componentDeploy "infrastructure" "Infrastructure"
componentDeploy "backend" "Backend"
componentDeploy "edge-lambda" "Edge-Lambda"
componentDeploy "post-deployment" "Post-Deployment"
goComponentDeploy "environment-tools" "Environment-Tools"

# We now need to invoke the post deployment lambda (we can do this locally)
#$EXEC sls invoke local -f postDeployment -s $STAGE
printf "\nInvoking post-deployment steps\n\n"
pushd "$SOLUTION_DIR/post-deployment" > /dev/null
$EXEC sls invoke -f postDeployment -l -s "$STAGE"
popd > /dev/null

# Dynamically set versionNumber and versionDate
# Get the first header (not Changelog) in CHANGELOG.md
versionLine="$(cat CHANGELOG.md | grep -m 1 "[0-9]\+\.[0-9]\+\.[0-9]\+\|Beta")"

Expand All @@ -69,7 +23,7 @@ else
fi

# Is there a stage.yml file?
FILE=main/config/settings/${STAGE}.yml
FILE="main/config/settings/$STAGE.yml"
if [ -f "$FILE" ]
then
# Yes-->Is there a versionDate and versionNumber key?
Expand All @@ -81,7 +35,7 @@ then
if ([ "$oldVersionNumber" != "$versionNumber" ]) || ([ "$oldVersionDate" != "$versionDate" ])
then
# Yes-->Replace new with old
sed -i -e "s/versionNumber: '$oldVersionNumber/versionNumber: '$versionNumber/" $FILE
sed -i -e "s/versionNumber: '$oldVersionNumber/versionNumber: '$versionNumber/" "$FILE"
sed -i -e "s/versionDate: '$oldVersionDate/versionDate: '$versionDate/" $FILE
fi
else
Expand All @@ -102,6 +56,53 @@ versionNumber: '${versionNumber}'
versionDate: '${versionDate}'" >> "$FILE"
fi

# Install
install_dependencies "$@"

function disableStats {
COMPONENT_DIR=$1
pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
# Disable serverless stats (only strictly needs to be done one time)
$EXEC sls slstats --disable -s "$STAGE"
popd > /dev/null
}

function componentDeploy {
COMPONENT_DIR=$1
COMPONENT_NAME=$2

pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
printf "\nDeploying component: %s ...\n\n" "$COMPONENT_NAME"
$EXEC sls deploy -s "$STAGE"
printf "\nDeployed component: %s successfully \n\n" "$COMPONENT_NAME"
popd > /dev/null
}

function goComponentDeploy() {
COMPONENT_DIR=$1
COMPONENT_NAME=$2

pushd "$SOLUTION_DIR/$COMPONENT_DIR" > /dev/null
printf "\nDeploying Go component: %s ...\n\n" "$COMPONENT_NAME"
$EXEC sls deploy-go -s "$STAGE"
printf "\nDeployed Go component: %s successfully \n\n" "$COMPONENT_NAME"
popd > /dev/null
}

disableStats "infrastructure"
componentDeploy "infrastructure" "Infrastructure"
componentDeploy "backend" "Backend"
componentDeploy "edge-lambda" "Edge-Lambda"
componentDeploy "post-deployment" "Post-Deployment"
goComponentDeploy "environment-tools" "Environment-Tools"

# We now need to invoke the post deployment lambda (we can do this locally)
#$EXEC sls invoke local -f postDeployment -s $STAGE
printf "\nInvoking post-deployment steps\n\n"
pushd "$SOLUTION_DIR/post-deployment" > /dev/null
$EXEC sls invoke -f postDeployment -l -s "$STAGE"
popd > /dev/null

# Deploy UI
pushd "$SOLUTION_DIR/ui" > /dev/null

Expand Down

0 comments on commit 6d545dd

Please sign in to comment.