Bu Sun Kim | e72202e | 2020-02-19 17:58:47 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2020 Google LLC |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Bu Sun Kim | e72202e | 2020-02-19 17:58:47 -0800 | [diff] [blame] | 16 | set -eo pipefail |
| 17 | |
| 18 | # Disable buffering, so that the logs stream through. |
| 19 | export PYTHONUNBUFFERED=1 |
| 20 | |
Tres Seaver | 000d0a0 | 2020-10-06 15:47:28 -0400 | [diff] [blame] | 21 | export PATH="${HOME}/.local/bin:${PATH}" |
Bu Sun Kim | e72202e | 2020-02-19 17:58:47 -0800 | [diff] [blame] | 22 | |
| 23 | # Install nox |
Tres Seaver | 000d0a0 | 2020-10-06 15:47:28 -0400 | [diff] [blame] | 24 | python3 -m pip install --user --upgrade --quiet nox |
| 25 | python3 -m nox --version |
Bu Sun Kim | e72202e | 2020-02-19 17:58:47 -0800 | [diff] [blame] | 26 | |
| 27 | # build docs |
| 28 | nox -s docs |
| 29 | |
Tres Seaver | 000d0a0 | 2020-10-06 15:47:28 -0400 | [diff] [blame] | 30 | python3 -m pip install --user gcp-docuploader |
Bu Sun Kim | e72202e | 2020-02-19 17:58:47 -0800 | [diff] [blame] | 31 | |
| 32 | # create metadata |
| 33 | python3 -m docuploader create-metadata \ |
| 34 | --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ |
| 35 | --version=$(python3 setup.py --version) \ |
| 36 | --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ |
| 37 | --distribution-name=$(python3 setup.py --name) \ |
| 38 | --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ |
| 39 | --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ |
| 40 | --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) |
| 41 | |
| 42 | cat docs.metadata |
| 43 | |
| 44 | # upload docs |
Tres Seaver | 000d0a0 | 2020-10-06 15:47:28 -0400 | [diff] [blame] | 45 | python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}" |
| 46 | |
| 47 | |
| 48 | # docfx yaml files |
| 49 | nox -s docfx |
| 50 | |
| 51 | # create metadata. |
| 52 | python3 -m docuploader create-metadata \ |
| 53 | --name=$(jq --raw-output '.name // empty' .repo-metadata.json) \ |
| 54 | --version=$(python3 setup.py --version) \ |
| 55 | --language=$(jq --raw-output '.language // empty' .repo-metadata.json) \ |
| 56 | --distribution-name=$(python3 setup.py --name) \ |
| 57 | --product-page=$(jq --raw-output '.product_documentation // empty' .repo-metadata.json) \ |
| 58 | --github-repository=$(jq --raw-output '.repo // empty' .repo-metadata.json) \ |
| 59 | --issue-tracker=$(jq --raw-output '.issue_tracker // empty' .repo-metadata.json) |
| 60 | |
| 61 | cat docs.metadata |
| 62 | |
| 63 | # upload docs |
| 64 | python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}" |