Commit 3c04d717 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Using clause 0 from toMkdocs.py script + version handling

parent d2aba895
Loading
Loading
Loading
Loading
+44 −18
Original line number Diff line number Diff line
@@ -39,12 +39,12 @@ git checkout $7

####### GENERATE NAV SPEC #######
echo "------ Generate input for mkdocs --------"
python3 $1 --title ${9^^} "./$8.md"
python3 $1 -it --title ${9^^} "./$8.md"
echo "------ Move to docs folder --------"
mv ${9^^}/* docs/
sed -i 's/'${9^^}'\///g' _nav.yml
cat _nav.yml >> mkdocs.yml
cp docs/1.md docs/index.md
cp docs/0.md docs/index.md

## Create download tab if official baseline version
if [[ ${10} == v* ]]; then
@@ -78,30 +78,56 @@ fi
if [ ${11} == "false" ]; then
    echo "------ Generating site --------"
    echo "Generating docs version ${10}..."
    majorVersion=$(echo ${10} | grep -o v[1-9]*\. | grep -o [1-9]*)
    majorVersion=$(echo ${10} | grep -o v[0-9]*\. | grep -o [0-9]*)
    interVersion=$(echo ${10} | cut -d. -f2)
    minorVersion=$(echo ${10} | cut -d. -f3)
    echo "Major version is ${majorVersion}"
    if [ -n "${majorVersion}" ]; then
        latest="latestR${majorVersion}"
        echo "Handling release ${latest}"
    fi

    if [ -z "${majorVersion}" ] || [ -z "${interVersion}" ] || [ -z "${minorVersion}" ]; then
        echo "Deploying non-versioned documents..."
        mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH ${10}
    else
      isPagesSet=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH)
      if [ -z "${isPagesSet}" ]; then
          mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u ${10} ${latest} latest
          mike set-default --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH latest #That's only needed the first time gl-pages is created
      else
        latestRelease=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep latest\, | grep -o latestR[1-9]*)
          latestVersionDeployed=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep ${latest} | cut -d" " -f1)
          latestVersionDeployed_inter=$(echo ${latestVersionDeployed} |cut -d. -f2 )
          latestVersionDeployed_minor=$(echo ${latestVersionDeployed} |cut -d. -f3 )
          latestRelease=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep latest\, | grep -o latestR[0-9]*)
          echo "Latest release is ${latestRelease}"
          echo "Latest deployed version for this release is ${latestVersionDeployed}"

          ##Handling versions: update latestRelease and latest (majorVersion updated)
          if [[ "${latest}" > "${latestRelease}" || "${latest}" == "${latestRelease}" ]]; then
            echo "Upgrade latest release..."
              echo "Upgrade latest release...deploying version ${10} as latest and ${latest}"
              mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u ${10} ${latest} latest
          else
            if [[ ${latestVersionDeployed_inter} < ${interVersion} || ${latestVersionDeployed_inter} == ${interVersion} ]]; then
              if [[ ${latestVersionDeployed_minor} < ${minorVersion} || ${latestVersionDeployed_minor} == ${minorVersion} ]]; then
                echo "Deploying version ${10} as ${latest}"
                mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH -u ${10} ${latest}
              fi
            fi
          fi

          ##Handling versions: hide version with editorial changes (minorVersion updated)
          if [[ ${latestVersionDeployed_inter} == ${interVersion} ]]; then
            if [[ ${latestVersionDeployed_minor} < ${minorVersion} ]]; then
              echo "Hidding version ${latestVersionDeployed}..."
              mike props --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH --set hidden=true "${latestVersionDeployed}"
            fi
          fi
      fi
    fi
else
    echo "------ Removing docs version ${11}..."
    majorVersion=$(echo ${11} | grep -o v[1-9]*\. | grep -o [1-9]*)
    majorVersion=$(echo ${11} | grep -o v[0-9]*\. | grep -o [0-9]*)
    if [ -n "${majorVersion}" ]; then
        previousVersion=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep v${majorVersion} | grep -A1 ${11} | grep -v ${11})
        latest="latestR${majorVersion}"
@@ -116,11 +142,11 @@ else
    ## Deal with alias latest
    if [ -n "${isLatest}" ]; then
        if [ -n "${previousVersion}" ]; then
            mike alias --deploy-prefix public -r $HTTPS_REMOTE --allow-empty -p -b $PAGES_BRANCH -u ${previousVersion} latest
            mike alias --deploy-prefix public -r $HTTPS_REMOTE --allow-empty -p -b $PAGES_BRANCH -u ${previousVersion} ${latest} latest
        else
            # Look previous release (previous major version)
            majorVersion=$(echo $((--majorVersion)))
            previousReleaseVersion=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep latestR${majorVersion} | grep -o v[1-9]*\.[0-9]*\.[0-9]*)
            previousReleaseVersion=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep latestR${majorVersion} | grep -o v[0-9]*\.[0-9]*\.[0-9]*)
            echo "Previous major version is ${majorVersion}"
            echo "Previous release version is ${previousReleaseVersion}"
            if [ -n "${previousReleaseVersion}" ]; then