Closed zrzka closed 8 years ago
Was thinking about additional arguments that can allow fatal in case of create-alias!
failure. Then decided not do it, because it complicates usage, adds another burden, ... If anyone uses :publish :alias XX
he simply wants to publish with this alias regardless if it exists or not. Can be described in documentation / wiki.
@robertvojta Thanks, I needed this. There's an ugly shell script which Travis runs, I'll add a line to it in the release branch.
Yeah, I've got crazy scripts like this one too.
#!/bin/bash
deploy() {
echo "Deploying $1 ..."
if FN_VERSION=$(lein cljs-lambda deploy $1 :publish :quiet 2>/dev/null | tail -n 1); then
if [[ -z $FN_VERSION ]]; then
echo "Can't get function version"
return 1
fi
if [ "$CI" != "true" ]; then
echo "Skipping aliasing, not CI"
return 0
fi
#
# By default we don't need alias update, because every published version is aliased
# with travis build number. But under some circumstances (build restart, ...), build
# number can be same. Thus we try to update first then create.
#
echo "Updating alias $1:$2 with version $FN_VERSION"
aws lambda update-alias --function-name $1 --name $2 --function-version $FN_VERSION
if [ $? -eq 0 ]; then
return 0
fi
echo "Creating alias $2:$3 -> $2:$FN_VERSION"
aws lambda create-alias --function-name $1 --name $2 --function-version $FN_VERSION
if [ $? -eq 0 ]; then
return 0
fi
echo "Failed to create alias"
return 1
fi
return 1
}
if [ -z "$1" ]; then
echo "Usage: $0 list-of-functions-to-deploy.txt"
exit 1
fi
if [ ! -f "$1" ]; then
echo "File not found: $1"
exit 1
fi
LAMBDA_ALIAS="build-$TRAVIS_BUILD_NUMBER"
NAMES="$(< "$1")"
for FUNC in $NAMES; do
deploy $FUNC $LAMBDA_ALIAS || exit 1
done
Based on issue #38. It allows:
:alias
with multiple functionsNo tests, didn't find them for plugin. Tested on my projects. Hope I didn't overlook something.