release.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. set -e
  3. set -o pipefail
  4. usage() {
  5. cat >&2 <<'EOF'
  6. To publish the Docker documentation you need to set your access_key and secret_key in the docs/awsconfig file
  7. (with the keys in a [profile $AWS_S3_BUCKET] section - so you can have more than one set of keys in your file)
  8. and set the AWS_S3_BUCKET env var to the name of your bucket.
  9. make AWS_S3_BUCKET=beta-docs.docker.io docs-release
  10. will then push the documentation site to your s3 bucket.
  11. EOF
  12. exit 1
  13. }
  14. [ "$AWS_S3_BUCKET" ] || usage
  15. #VERSION=$(cat VERSION)
  16. export BUCKET=$AWS_S3_BUCKET
  17. export AWS_CONFIG_FILE=$(pwd)/awsconfig
  18. [ -e "$AWS_CONFIG_FILE" ] || usage
  19. export AWS_DEFAULT_PROFILE=$BUCKET
  20. echo "cfg file: $AWS_CONFIG_FILE ; profile: $AWS_DEFAULT_PROFILE"
  21. setup_s3() {
  22. echo "Create $BUCKET"
  23. # Try creating the bucket. Ignore errors (it might already exist).
  24. aws s3 mb s3://$BUCKET 2>/dev/null || true
  25. # Check access to the bucket.
  26. echo "test $BUCKET exists"
  27. aws s3 ls s3://$BUCKET
  28. # Make the bucket accessible through website endpoints.
  29. echo "make $BUCKET accessible as a website"
  30. #aws s3 website s3://$BUCKET --index-document index.html --error-document jsearch/index.html
  31. s3conf=$(cat s3_website.json | envsubst)
  32. echo
  33. echo $s3conf
  34. echo
  35. aws s3api put-bucket-website --bucket $BUCKET --website-configuration "$s3conf"
  36. }
  37. build_current_documentation() {
  38. mkdocs build
  39. }
  40. upload_current_documentation() {
  41. src=site/
  42. dst=s3://$BUCKET
  43. echo
  44. echo "Uploading $src"
  45. echo " to $dst"
  46. echo
  47. #s3cmd --recursive --follow-symlinks --preserve --acl-public sync "$src" "$dst"
  48. aws s3 sync --cache-control "max-age=3600" --acl public-read --exclude "*.rej" --exclude "*.rst" --exclude "*.orig" --exclude "*.py" "$src" "$dst"
  49. }
  50. setup_s3
  51. build_current_documentation
  52. upload_current_documentation