From 0d2cdfc55a8a8f8099a3081397966de623982997 Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Tue, 28 Sep 2021 13:10:56 +0200 Subject: [PATCH 1/7] update documentation workflow to only publish one version per major --- .github/workflows/documentation.yml | 74 +++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 00c8595fdec0..7d8c86ac6dc1 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -2,8 +2,6 @@ name: Publish Documentation on: push: - branches: - - 'main' tags: - '**' @@ -15,12 +13,82 @@ on: env: DOCS_FOLDER: docs DOCS_BRANCH: documentation + TAG_NAME: ${GITHUB_REF#refs/tags/} jobs: + evaluate_release_tag: + name: Evaluate release tag + runs-on: ubuntu-latest + if: github.repository == 'RasaHQ/rasa' # don't run this for main branches of forks, would fail anyways + outputs: + build_docs: ${{ steps.check_tag.outputs.build_docs }} + + steps: + - name: Checkout git repository 🕝 + uses: actions/checkout@v2 + + - name: Check if tag version is equal or higher than the latest tagged Rasa version + id: rasa_get_version + run: | + # Get latest tagged Rasa version + git fetch --depth=1 origin "+refs/tags/*:refs/tags/*" + # Fetch branch history + git fetch --prune --unshallow + LATEST_TAGGED_NON_ALPHA_RASA_VERSION=$(git tag | sort -r -V | grep -E "^[0-9.]+$" | head -n1) + + echo "LATEST_TAGGED_NON_ALPHA_RASA_VERSION=${LATEST_TAGGED_NON_ALPHA_RASA_VERSION}" >> $GITHUB_ENV + + CURRENT_TAG=${GITHUB_REF#refs/tags/} + # Return 'true' if tag version is equal or higher than the latest tagged Rasa version + IS_LATEST_VERSION=$((printf '%s\n%s\n' "${LATEST_TAGGED_NON_ALPHA_RASA_VERSION}" "$CURRENT_TAG" \ + | sort -V -C && echo true || echo false) || true) + + + if [[ "${IS_LATEST_VERSION}" == "true" && "$CURRENT_TAG" =~ ^[0-9.]+$ ]]; then + echo "::set-output name=is_latest_version::true" + else + echo "::set-output name=is_latest_version::false" + fi + + + # MAJOR.MINOR.MICRO(PATCH) + # docs are built on every minor tag for the latest major (when 3.0 is out, the latest major is 3.0) + # (technically it'll be always the latest version) + # + # docs are built on every micro tag for the latest minor of + # - the latest major (when 3.0 is out, the latest major is 3.0) + # - the previous major (when 3.0 is out, the previous major is 2.0, the latest minor on this version being 2.8) + - name: Check if it's a micro tag for the latest minor + id: check_tag + run: | + IS_LATEST_VERSION=${{ steps.rasa_get_version.outputs.is_latest_version }} + + # the latest major (when 3.0 is out, the latest major is 3.0) + if [[ "${IS_LATEST_VERSION}" == "true" ]]; then + echo "::set-output name=build_docs::true" + exit 0 + fi + + # the previous major (when 3.0 is out, the previous major is 2.0, the latest minor on this version being 2.8) + CURRENT_MAJOR_VERSION=$(echo ${LATEST_TAGGED_NON_ALPHA_RASA_VERSION} | awk -F\. '{print $1}') + PREVIOUS_MAJOR_LATEST_VERSION=$(git tag | sort -r -V | grep -E "^[0-9.]+$" | grep -vE "^${CURRENT_MAJOR_VERSION}" | head -n1) + + # Return 'true' if tag version is equal or higher than the latest previous major version + IS_PREVIOUS_MAJOR_LATEST_VERSION=$((printf '%s\n%s\n' "${PREVIOUS_MAJOR_LATEST_VERSION}" "$TAG_NAME" \ + | sort -V -C && echo true || echo false) || true) + + if [[ "${IS_PREVIOUS_MAJOR_LATEST_VERSION}" == "true" ]]; then + echo "::set-output name=build_docs::true" + exit 0 + fi + + echo "::set-output name=build_docs::false" + docs: name: Build Docs runs-on: ubuntu-latest - if: github.repository == 'RasaHQ/rasa' # don't run this for main branches of forks, would fail anyways + needs: [ evaluate_release_tag ] + if: github.repository == 'RasaHQ/rasa' && needs.evaluate_release_tag.outputs.check_tag == 'true' # don't run this for main branches of forks, would fail anyways steps: - name: Checkout git repository 🕝 From 703c59eb02c5734f6673cc642f14d93b0ff9ba2d Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Tue, 28 Sep 2021 13:13:59 +0200 Subject: [PATCH 2/7] Check if condition --- .github/workflows/documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7d8c86ac6dc1..9d8a466170c7 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -88,7 +88,7 @@ jobs: name: Build Docs runs-on: ubuntu-latest needs: [ evaluate_release_tag ] - if: github.repository == 'RasaHQ/rasa' && needs.evaluate_release_tag.outputs.check_tag == 'true' # don't run this for main branches of forks, would fail anyways + if: github.repository == 'RasaHQ/rasa' && needs.evaluate_release_tag.outputs.build_docs == 'true' # don't run this for main branches of forks, would fail anyways steps: - name: Checkout git repository 🕝 From 79dd77864afc812268cf9f1f74f7e2a24192cc7f Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Wed, 29 Sep 2021 11:24:33 +0200 Subject: [PATCH 3/7] Add the main branch + small improvements --- .github/workflows/documentation.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 9d8a466170c7..61a38cd1ad7b 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -2,6 +2,8 @@ name: Publish Documentation on: push: + branches: + - 'main' tags: - '**' @@ -14,6 +16,7 @@ env: DOCS_FOLDER: docs DOCS_BRANCH: documentation TAG_NAME: ${GITHUB_REF#refs/tags/} + IS_TAG_BUILD: ${{ startsWith(github.event.ref, 'refs/tags') }} jobs: evaluate_release_tag: @@ -38,13 +41,12 @@ jobs: echo "LATEST_TAGGED_NON_ALPHA_RASA_VERSION=${LATEST_TAGGED_NON_ALPHA_RASA_VERSION}" >> $GITHUB_ENV - CURRENT_TAG=${GITHUB_REF#refs/tags/} # Return 'true' if tag version is equal or higher than the latest tagged Rasa version - IS_LATEST_VERSION=$((printf '%s\n%s\n' "${LATEST_TAGGED_NON_ALPHA_RASA_VERSION}" "$CURRENT_TAG" \ + IS_LATEST_VERSION=$((printf '%s\n%s\n' "${LATEST_TAGGED_NON_ALPHA_RASA_VERSION}" "$TAG_NAME" \ | sort -V -C && echo true || echo false) || true) - if [[ "${IS_LATEST_VERSION}" == "true" && "$CURRENT_TAG" =~ ^[0-9.]+$ ]]; then + if [[ "${IS_LATEST_VERSION}" == "true" && "$TAG_NAME" =~ ^[0-9.]+$ ]]; then echo "::set-output name=is_latest_version::true" else echo "::set-output name=is_latest_version::false" @@ -59,6 +61,7 @@ jobs: # - the latest major (when 3.0 is out, the latest major is 3.0) # - the previous major (when 3.0 is out, the previous major is 2.0, the latest minor on this version being 2.8) - name: Check if it's a micro tag for the latest minor + if: env.IS_TAG_BUILD == 'true' id: check_tag run: | IS_LATEST_VERSION=${{ steps.rasa_get_version.outputs.is_latest_version }} @@ -88,7 +91,7 @@ jobs: name: Build Docs runs-on: ubuntu-latest needs: [ evaluate_release_tag ] - if: github.repository == 'RasaHQ/rasa' && needs.evaluate_release_tag.outputs.build_docs == 'true' # don't run this for main branches of forks, would fail anyways + if: github.repository == 'RasaHQ/rasa' && (needs.evaluate_release_tag.outputs.build_docs == 'true' || github.ref == 'refs/heads/main' ) # don't run this for main branches of forks, would fail anyways steps: - name: Checkout git repository 🕝 From d5e7da2a5dfae8b466472457f435ac12dc1ea97f Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Wed, 29 Sep 2021 11:51:35 +0200 Subject: [PATCH 4/7] Adjust the push_docs_to_branch.sh --- scripts/push_docs_to_branch.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/push_docs_to_branch.sh b/scripts/push_docs_to_branch.sh index 8009fdd351dc..3cf9a5894cdb 100755 --- a/scripts/push_docs_to_branch.sh +++ b/scripts/push_docs_to_branch.sh @@ -33,10 +33,10 @@ NEW_VERSION= EXISTING_VERSION= if [[ "$GITHUB_REF" =~ $PATTERN_FOR_NEW_VERSION ]] then - NEW_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.0$/\1.\2.x/") + NEW_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.0$/\1.x/") elif [[ "$GITHUB_REF" =~ $PATTERN_FOR_MICRO_VERSION ]] then - EXISTING_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.[0-9]+$/\1.\2.x/") + EXISTING_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.[0-9]+$/\1.x/") fi # clone the $DOCS_BRANCH in a temp directory From f2ec76bfd948e598a5fb9b2d150c346b50dd871a Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Thu, 30 Sep 2021 16:52:44 +0200 Subject: [PATCH 5/7] improvements Signed-off-by: tczekajlo --- .github/workflows/documentation.yml | 6 ++++-- scripts/push_docs_to_branch.sh | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 61a38cd1ad7b..b9b6ac79a41d 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,6 +17,7 @@ env: DOCS_BRANCH: documentation TAG_NAME: ${GITHUB_REF#refs/tags/} IS_TAG_BUILD: ${{ startsWith(github.event.ref, 'refs/tags') }} + IS_MASTER_BRANCH: ${{ github.ref == 'refs/heads/main' }} jobs: evaluate_release_tag: @@ -67,7 +68,8 @@ jobs: IS_LATEST_VERSION=${{ steps.rasa_get_version.outputs.is_latest_version }} # the latest major (when 3.0 is out, the latest major is 3.0) - if [[ "${IS_LATEST_VERSION}" == "true" ]]; then + # build docs on push to the main branch + if [[ "${IS_LATEST_VERSION}" == "true" || "${IS_MASTER_BRANCH}" == "true" ]]; then echo "::set-output name=build_docs::true" exit 0 fi @@ -91,7 +93,7 @@ jobs: name: Build Docs runs-on: ubuntu-latest needs: [ evaluate_release_tag ] - if: github.repository == 'RasaHQ/rasa' && (needs.evaluate_release_tag.outputs.build_docs == 'true' || github.ref == 'refs/heads/main' ) # don't run this for main branches of forks, would fail anyways + if: github.repository == 'RasaHQ/rasa' && needs.evaluate_release_tag.outputs.build_docs == 'true' # don't run this for main branches of forks, would fail anyways steps: - name: Checkout git repository 🕝 diff --git a/scripts/push_docs_to_branch.sh b/scripts/push_docs_to_branch.sh index 3cf9a5894cdb..4674bd449d9a 100755 --- a/scripts/push_docs_to_branch.sh +++ b/scripts/push_docs_to_branch.sh @@ -14,7 +14,7 @@ set -Eeuo pipefail TODAY=`date "+%Y%m%d"` # we build new versions only for minors and majors -PATTERN_FOR_NEW_VERSION="^refs/tags/[0-9]+\\.[0-9]+\\.0$" +PATTERN_FOR_NEW_VERSION="^refs/tags/[0-9]+\\.0\\.0$" PATTERN_FOR_MICRO_VERSION="^refs/tags/[0-9]+\\.[0-9]+\\.[1-9][0-9]*$" MAIN_REF=refs/heads/main VARIABLES_JSON=docs/docs/variables.json @@ -34,9 +34,11 @@ EXISTING_VERSION= if [[ "$GITHUB_REF" =~ $PATTERN_FOR_NEW_VERSION ]] then NEW_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.0$/\1.x/") + if [[ -n ${CI} ]]; then echo "New version: ${NEW_VERSION}"; fi elif [[ "$GITHUB_REF" =~ $PATTERN_FOR_MICRO_VERSION ]] then EXISTING_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.[0-9]+$/\1.x/") + if [[ -n ${CI} ]]; then echo "Existing version: ${EXISTING_VERSION}"; fi fi # clone the $DOCS_BRANCH in a temp directory From 5ac6787721db1365ddad2f6137affb43fcc2e0d0 Mon Sep 17 00:00:00 2001 From: Tomasz Czekajlo Date: Fri, 1 Oct 2021 11:22:56 +0200 Subject: [PATCH 6/7] Update scripts/push_docs_to_branch.sh Co-authored-by: Maxime Vdb --- scripts/push_docs_to_branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/push_docs_to_branch.sh b/scripts/push_docs_to_branch.sh index 4674bd449d9a..3dc2672f58a6 100755 --- a/scripts/push_docs_to_branch.sh +++ b/scripts/push_docs_to_branch.sh @@ -15,7 +15,7 @@ set -Eeuo pipefail TODAY=`date "+%Y%m%d"` # we build new versions only for minors and majors PATTERN_FOR_NEW_VERSION="^refs/tags/[0-9]+\\.0\\.0$" -PATTERN_FOR_MICRO_VERSION="^refs/tags/[0-9]+\\.[0-9]+\\.[1-9][0-9]*$" +PATTERN_FOR_EXISTING_VERSION="^refs/tags/[0-9]+\\.[0-9]+\\.[0-9]+$" MAIN_REF=refs/heads/main VARIABLES_JSON=docs/docs/variables.json SOURCES_FILES=docs/docs/sources/ From 5040ece5eb6fcd62345f3d7ab96180e5dff31fba Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Mon, 4 Oct 2021 16:57:51 +0200 Subject: [PATCH 7/7] Change a env variable name --- scripts/push_docs_to_branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/push_docs_to_branch.sh b/scripts/push_docs_to_branch.sh index 3dc2672f58a6..c45266f7448f 100755 --- a/scripts/push_docs_to_branch.sh +++ b/scripts/push_docs_to_branch.sh @@ -35,7 +35,7 @@ if [[ "$GITHUB_REF" =~ $PATTERN_FOR_NEW_VERSION ]] then NEW_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.0$/\1.x/") if [[ -n ${CI} ]]; then echo "New version: ${NEW_VERSION}"; fi -elif [[ "$GITHUB_REF" =~ $PATTERN_FOR_MICRO_VERSION ]] +elif [[ "$GITHUB_REF" =~ $PATTERN_FOR_EXISTING_VERSION ]] then EXISTING_VERSION=$(echo $GITHUB_REF | sed -E "s/^refs\/tags\/([0-9]+)\.([0-9]+)\.[0-9]+$/\1.x/") if [[ -n ${CI} ]]; then echo "Existing version: ${EXISTING_VERSION}"; fi