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
16set -eo pipefail
17
18# Disable buffering, so that the logs stream through.
19export PYTHONUNBUFFERED=1
20
21export PATH="${HOME}/.local/bin:${PATH}"
22
23# Install nox
24python3 -m pip install --user --upgrade --quiet nox
25python3 -m nox --version
26
27# build docs
28nox -s docs
29
30python3 -m pip install --user gcp-docuploader
31
32# create metadata
33python3 -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
42cat docs.metadata
43
44# upload docs
45python3 -m docuploader upload docs/_build/html --metadata-file docs.metadata --staging-bucket "${STAGING_BUCKET}"
46
47
48# docfx yaml files
49nox -s docfx
50
51# create metadata.
52python3 -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
61cat docs.metadata
62
63# upload docs
64python3 -m docuploader upload docs/_build/html/docfx_yaml --metadata-file docs.metadata --destination-prefix docfx --staging-bucket "${V2_STAGING_BUCKET}"
65