2022-05-30 13:40:19 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e # exit on error
|
|
|
|
|
|
|
|
# TODO: Update script!
|
|
|
|
|
|
|
|
VERSION=$(node scripts/version.js)
|
|
|
|
VERSION_TAG=v${VERSION:0:1}.x
|
|
|
|
|
|
|
|
copy_to_s3 () {
|
2022-05-31 16:16:03 +03:00
|
|
|
aws s3 cp bundles "s3://redocly-cdn/redoc/$1/bundles" --recursive
|
|
|
|
aws s3 cp CHANGELOG.md "s3://redocly-cdn/redoc/$1/CHANGELOG.md"
|
|
|
|
aws s3 cp LICENSE "s3://redocly-cdn/redoc/$1/LICENSE"
|
|
|
|
aws s3 cp package.json "s3://redocly-cdn/redoc/$1/package.json"
|
|
|
|
aws s3 cp README.md "s3://redocly-cdn/redoc/$1/README.md"
|
2022-05-30 13:40:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if aws s3 ls "redocly-cdn/redoc/v$VERSION/" "$@"; then
|
|
|
|
echo "Version $VERSION already exists"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo Releasing $VERSION
|
|
|
|
|
|
|
|
echo Uploading to S3 $VERSION
|
2022-05-31 16:16:03 +03:00
|
|
|
copy_to_s3 "v$VERSION"
|
2022-05-30 13:40:19 +03:00
|
|
|
|
|
|
|
echo Uploading to S3 $VERSION_TAG
|
|
|
|
copy_to_s3 "$VERSION_TAG" $@
|
|
|
|
|
|
|
|
if [[ "$VERSION_TAG" == "v2.x" ]]; then
|
|
|
|
echo Uploading to S3 latest
|
|
|
|
copy_to_s3 latest $@
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo Deployed successfully
|
|
|
|
exit 0
|
|
|
|
fi
|