From db827256fa4fd13ebbb8a455bd2ad834be5c072a Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 3 Sep 2020 09:21:57 +0100 Subject: [PATCH 1/4] Docs: Update where 4.0.0 is built from, add 4.0.1 - means we can delete the old `docs-versioning` branch - both versions point to the same commit (when branch merged to master), but reduces user confusion when they can't find the docs for the latest released version. Going forward this will point directly to the release label --- website/internal-versions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/internal-versions.json b/website/internal-versions.json index 3db52ab73b..2635ffaea2 100644 --- a/website/internal-versions.json +++ b/website/internal-versions.json @@ -1,3 +1,4 @@ [ - "4.0.0:docs-versioning:true" + "4.0.1:372682177452d8d:true", + "4.0.0:372682177452d8d:true" ] From e22fdd37aec518b13373e05beb6d2df401d2dcc6 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 9 Sep 2020 10:55:27 +0100 Subject: [PATCH 2/4] Automatically update website's internal-versions.json on new releases - Add new github action - Action will trigger on a release being published - Action looks at github `release` object associated with event and extracts a version label and git label - Use extracted values adds new value to internal-versions.json - Creates a PR with the change --- .../workflows/documentation-versioning.yml | 40 +++++++++++++++++++ website/add-version.sh | 27 +++++++++++++ website/package.json | 1 + 3 files changed, 68 insertions(+) create mode 100644 .github/workflows/documentation-versioning.yml create mode 100755 website/add-version.sh diff --git a/.github/workflows/documentation-versioning.yml b/.github/workflows/documentation-versioning.yml new file mode 100644 index 0000000000..62e7809004 --- /dev/null +++ b/.github/workflows/documentation-versioning.yml @@ -0,0 +1,40 @@ +name: documentation-versions + +on: + release: + types: [published] + +jobs: + update-docs-internal-versions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + - name: Update internal-versions.json + run: | + cd website + if [ -e yarn.lock ]; then + yarn install --frozen-lockfile + elif [ -e package-lock.json ]; then + npm ci + else + npm i + fi + npm run add-version + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v3 + with: + commit-message: Update Docs Versions + delete-branch: true + title: Update website docs version following release + body: | + - Auto-generated + labels: | + ready for review + draft: false + - name: Check output + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" \ No newline at end of file diff --git a/website/add-version.sh b/website/add-version.sh new file mode 100755 index 0000000000..b8fd451e87 --- /dev/null +++ b/website/add-version.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e +set -o pipefail + +echo "Determining version Label & Tag" + +# GITHUB_EVENT_PATH points to json containing event data. This contains the github release object +# See https://developer.github.com/webhooks/event-payloads/#release +versionLabel=$(jq -r '.release.name' $GITHUB_EVENT_PATH) +versionSha=$(jq -r '.release.tag_name' $GITHUB_EVENT_PATH) +showVersionInDropDown=true +internalVersionsFile="internal-versions.json" + +echo Adding the following as latest docs version +echo "Label : $versionLabel" +echo "Tag/Sha : $versionSha" +echo "Show In Dropdown : $showVersionInDropDown" + +interalVersion=$versionLabel:$versionSha:$showVersionInDropDown +echo "New Version : $interalVersion" + +# Write to temp env var. Not sure why, but a simple `> $internalVersionsFile` wipes out content +res=$(jq --arg argval $interalVersion -r '. |= [$argval] + .' $internalVersionsFile) +echo "$res" > $internalVersionsFile + +echo "Result :" +cat $internalVersionsFile diff --git a/website/package.json b/website/package.json index 641c266894..c2ae0c4742 100644 --- a/website/package.json +++ b/website/package.json @@ -10,6 +10,7 @@ "deploy": "./deploy.sh", "version": "docusaurus docs:version", "versions": "./build-versions.sh", + "add-version": "./add-version.sh", "docusaurus": "docusaurus", "serve": "docusaurus serve" }, From e5f9c491ad047ed1e40b56c4c6d281b58bec74bb Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Wed, 9 Sep 2020 11:16:52 +0100 Subject: [PATCH 3/4] Fix checkout issue --- website/build-versions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/build-versions.sh b/website/build-versions.sh index ffe302efc7..2959642ebe 100755 --- a/website/build-versions.sh +++ b/website/build-versions.sh @@ -23,7 +23,8 @@ function cleanUpBefore() ( function gitClone() ( rurl="$1" localdir="$2" echo "Cloning from $rurl into $localdir" - git clone --depth 1 --no-single-branch $rurl $localdir + # git clone --depth 1 --no-single-branch $rurl $localdir + git clone $rurl $localdir pushd $localdir/website > /dev/null npm install popd > /dev/null From a243332d58b9451a75e04575de37ea4c1f981615 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 10 Sep 2020 10:52:55 +0100 Subject: [PATCH 4/4] Update documentation-versioning.yml --- .github/workflows/documentation-versioning.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/documentation-versioning.yml b/.github/workflows/documentation-versioning.yml index 62e7809004..76eab9369b 100644 --- a/.github/workflows/documentation-versioning.yml +++ b/.github/workflows/documentation-versioning.yml @@ -25,7 +25,7 @@ jobs: npm run add-version - name: Create Pull Request id: cpr - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v3.3.0 with: commit-message: Update Docs Versions delete-branch: true @@ -37,4 +37,4 @@ jobs: draft: false - name: Check output run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" \ No newline at end of file + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"