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

Fix for removing any version from the spec site

parent aaae9122
Loading
Loading
Loading
Loading
Loading
+122 −109
Original line number Diff line number Diff line
@@ -52,13 +52,22 @@ PAGES_BRANCH=gl-pages
HTTPS_REMOTE=https://gitlab-ci-token:${MIKE_ACCESS_TOKEN}@${CI_SERVER_FQDN}/${CI_PROJECT_PATH}.git

# Parse vX.Y.Z into numeric components (base 10, so 9 < 10 works correctly).
# Sets PARSE_IS_SEMVER=true only for tags matching v?X.Y.Z(.N)* ; otherwise leaves components empty.
parse_semver() {
    local tag
    tag=$(echo "$1" | tr -d '\r\n' | xargs)
    PARSE_IS_SEMVER=false
    PARSE_MAJOR=""
    PARSE_INTER=""
    PARSE_MINOR=""

    if [[ "${tag}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)*$ ]]; then
        PARSE_IS_SEMVER=true
        tag="${tag#v}"
        PARSE_MAJOR=$((10#$(echo "${tag}" | cut -d. -f1)))
        PARSE_INTER=$((10#$(echo "${tag}" | cut -d. -f2)))
        PARSE_MINOR=$((10#$(echo "${tag}" | cut -d. -f3)))
    fi
}

echo "\n------ Install necessary packages --------"
@@ -319,6 +328,10 @@ if [ ${CLEAN_WEB_PAGES} == "false" ]; then
    echo "------ Generating site --------"
    echo "Generating docs version ${TAG_NAME}..."
    parse_semver "${TAG_NAME}"
    if [ "${PARSE_IS_SEMVER}" != "true" ]; then
        echo "Tag '${TAG_NAME}' is not semver (vX.Y.Z): deploying as non-versioned document..."
        mike deploy --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH ${TAG_NAME}
    else
        majorVersion=${PARSE_MAJOR}
        interVersion=${PARSE_INTER}
        minorVersion=${PARSE_MINOR}
@@ -328,10 +341,6 @@ if [ ${CLEAN_WEB_PAGES} == "false" ]; then
            echo "Handling release ${releaseVersion}"
        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 ${TAG_NAME}
    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 ${TAG_NAME} ${releaseVersion} latest
@@ -406,15 +415,18 @@ if [ ${CLEAN_WEB_PAGES} == "false" ]; then
        fi
    fi  
else
    echo "------ Removing docs version  }..."
    echo "------ Removing docs version ${CLEAN_WEB_PAGES}..."
    parse_semver "${CLEAN_WEB_PAGES}"

    if [ "${PARSE_IS_SEMVER}" != "true" ]; then
        echo "Tag '${CLEAN_WEB_PAGES}' is not semver (vX.Y.Z): deleting published version only."
        mike delete --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH ${CLEAN_WEB_PAGES}
    else
        majorVersion=${PARSE_MAJOR}
    if [[ "${CLEAN_WEB_PAGES}" == v* ]]; then
        previousVersion=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH | grep v${majorVersion} | grep -A1 ${CLEAN_WEB_PAGES} | grep -v ${CLEAN_WEB_PAGES})
        releaseVersion="latestR${majorVersion}"
        echo "Major version is ${majorVersion}"
        echo "Previous version is ${previousVersion}"
    fi

        isLatest=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH ${CLEAN_WEB_PAGES} | grep -o latest\, )
        isLatestRelease=$(mike list --deploy-prefix public -r $HTTPS_REMOTE -b $PAGES_BRANCH ${CLEAN_WEB_PAGES} | grep -o ${releaseVersion} )
@@ -449,6 +461,7 @@ else

        mike delete --deploy-prefix public -r $HTTPS_REMOTE -p -b $PAGES_BRANCH ${CLEAN_WEB_PAGES}
    fi
fi

git checkout "${PAGES_BRANCH}" -- public/
#if git show-ref --verify --quiet "refs/heads/${PAGES_BRANCH}" \
@@ -465,11 +478,11 @@ ls public/
#ls public/ 2>/dev/null || echo "public/ not available"


echo "Content of public/${TAG_NAME}..."
ls public/${TAG_NAME}
#echo "Content of public/${TAG_NAME}..."
#ls public/${TAG_NAME}

echo "Content of public/${TAG_NAME}/release_notes_diff..."
ls public/${TAG_NAME}/release_notes_diff
#echo "Content of public/${TAG_NAME}/release_notes_diff..."
#ls public/${TAG_NAME}/release_notes_diff

exit 0