|
| 1 | +# Make sure the release_version was passed as an argument |
| 2 | +if [ $# -eq 0 ]; then |
| 3 | + echo "Missing release_version argument." |
| 4 | + echo "Usage: CircleciScripts/release_javadoc.sh major.minor.patch" |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +release_version=$1 |
| 9 | + |
| 10 | +# Make sure the git repo is not dirty, since this script switches branches and commits changes. |
| 11 | +if [ "$(git status --porcelain)" ]; then |
| 12 | + echo "Your git repo is dirty. Commit or revert all changes before running this script." |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +# Make sure this script is run from the project root. |
| 17 | +if [[ ! -d "CircleciScripts" ]] |
| 18 | +then |
| 19 | + echo "No CircleciScripts folder found. This script must be run from the project root." |
| 20 | + exit 1 |
| 21 | +fi |
| 22 | + |
| 23 | +# generate documents |
| 24 | +projectRoot=$(pwd) |
| 25 | +configFile="CircleciScripts/ReleaseConfiguration.json" |
| 26 | +destinationPath="build/javadoc" |
| 27 | +sdkPath="$HOME/Library/Android/sdk/platforms/android-29/" |
| 28 | + |
| 29 | +## Make sure the Android SDK is installed at the expected place |
| 30 | +if [[ ! -f "${sdkPath}android.jar" ]] |
| 31 | +then |
| 32 | + echo "Failed to find Android library at ${sdkPath}android.jar." |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +python3 CircleciScripts/generate_javadoc.py "$configFile" "$projectRoot" "$destinationPath" "$sdkPath" "$release_version" |
| 37 | + |
| 38 | +# check out gh-pages and preserve old document |
| 39 | +git fetch |
| 40 | +git checkout gh-pages |
| 41 | +git checkout main CircleciScripts/preserve_olddocument.sh |
| 42 | +release_version=$release_version bash CircleciScripts/preserve_olddocument.sh |
| 43 | + |
| 44 | +# copy new document |
| 45 | +rm -rf docs/reference |
| 46 | +mkdir -p docs/reference |
| 47 | +cp -R build/javadoc/* docs/reference/ |
| 48 | + |
| 49 | +# check in documents |
| 50 | +git add docs/reference |
| 51 | +git rm --cached preserve_olddocument.sh |
| 52 | +git commit -m "AWS SDK for Android $release_version" |
| 53 | +git push |
| 54 | + |
| 55 | +# Add documentation tags to gh-pages |
| 56 | +git tag -a "docs_v$release_version" -m "Add documentation tags to version $release_version" |
| 57 | +git push --tags |
| 58 | + |
| 59 | +# Switch back to the main branch |
| 60 | +git checkout main |
0 commit comments