release.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. 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)
  32. aws s3api put-bucket-website --bucket $BUCKET --website-configuration "$s3conf"
  33. }
  34. build_current_documentation() {
  35. mkdocs build
  36. }
  37. upload_current_documentation() {
  38. src=site/
  39. dst=s3://$BUCKET
  40. echo
  41. echo "Uploading $src"
  42. echo " to $dst"
  43. echo
  44. #s3cmd --recursive --follow-symlinks --preserve --acl-public sync "$src" "$dst"
  45. aws s3 sync --acl public-read --exclude "*.rej" --exclude "*.rst" --exclude "*.orig" --exclude "*.py" "$src" "$dst"
  46. }
  47. setup_s3
  48. build_current_documentation
  49. upload_current_documentation