From f467f5ba94893abd3fc0ba7ba53203958c5e78cf Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 20 Jun 2023 13:40:43 +0000 Subject: [PATCH 1/5] fix(docs): ensure versions.json is updated --- .github/workflows/reusable_publish_docs.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index 2e40d1d1f0d..d9bfee5c2c0 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -83,6 +83,18 @@ jobs: - name: Copy API Docs run: | cp -r api site/ + - name: Deploy Docs (Version) + env: + VERSION: ${{ inputs.version }} + ALIAS: ${{ inputs.alias }} + run: | + aws s3 cp \ + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \ + versions_old.json + jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": []}]' < versions_old.json > versions.json + aws s3 cp \ + versions.json \ + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json - name: Deploy Docs (Version) env: VERSION: ${{ inputs.version }} From 292ce975073a6ae687543573d48585a935fdc700 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 20 Jun 2023 16:58:49 +0200 Subject: [PATCH 2/5] Update reusable_publish_docs.yml Signed-off-by: Simon Thulbourn --- .github/workflows/reusable_publish_docs.yml | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index d9bfee5c2c0..bea034d4700 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -83,18 +83,6 @@ jobs: - name: Copy API Docs run: | cp -r api site/ - - name: Deploy Docs (Version) - env: - VERSION: ${{ inputs.version }} - ALIAS: ${{ inputs.alias }} - run: | - aws s3 cp \ - s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \ - versions_old.json - jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": []}]' < versions_old.json > versions.json - aws s3 cp \ - versions.json \ - s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json - name: Deploy Docs (Version) env: VERSION: ${{ inputs.version }} @@ -111,3 +99,16 @@ jobs: aws s3 sync \ site/ \ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/${{ env.ALIAS }}/ + - name: Deploy Docs (Version JSON) + env: + VERSION: ${{ inputs.version }} + ALIAS: ${{ inputs.alias }} + run: | + aws s3 cp \ + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \ + versions_old.json + jq 'del(.[].aliases[] | select(. == "stage"))' < versions_old.json > versions_proc.json + jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["latest"]}]' < versions_proc.json > versions.json + aws s3 cp \ + versions.json \ + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json From 35104fec2e8f32a71754933ca4e5e59486d62125 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 20 Jun 2023 17:22:15 +0200 Subject: [PATCH 3/5] adds some comments to the stanza Signed-off-by: Simon Thulbourn --- .github/workflows/reusable_publish_docs.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index bea034d4700..046bfb34213 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -103,12 +103,24 @@ jobs: env: VERSION: ${{ inputs.version }} ALIAS: ${{ inputs.alias }} + # We originally used "mike" from PyPi to manage versions for us, but since we moved to S3, we can't use it to manage versions any more. + # Instead, we're using some shell script that manages the versions. + # + # Operations: + # 1. Download the versions.json file from S3 + # 2. Find any reference to the alias and delete it from the versions file + # 3. We insert the new version to the versions.json file with the corresponding alias + # 4. Once done, we'll upload it back to S3. run: | aws s3 cp \ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \ versions_old.json - jq 'del(.[].aliases[] | select(. == "stage"))' < versions_old.json > versions_proc.json - jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["latest"]}]' < versions_proc.json > versions.json + jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json + jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"]}]' < versions_proc.json > versions.json aws s3 cp \ versions.json \ - s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json + jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": []}]' < versions_old.json > versions.json + aws s3 cp \ + versions.json \ + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json From 2a72426d67080495d7cb1c0dd0926e267d993552 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Tue, 20 Jun 2023 17:25:11 +0200 Subject: [PATCH 4/5] remove dupe code Signed-off-by: Simon Thulbourn --- .github/workflows/reusable_publish_docs.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index 046bfb34213..641b810b862 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -120,7 +120,3 @@ jobs: aws s3 cp \ versions.json \ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json - jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": []}]' < versions_old.json > versions.json - aws s3 cp \ - versions.json \ - s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json From 85054651fafc8f32aa714b145775cd412e7961fd Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Fri, 23 Jun 2023 12:48:46 +0200 Subject: [PATCH 5/5] Update reusable_publish_docs.yml Signed-off-by: Simon Thulbourn --- .github/workflows/reusable_publish_docs.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable_publish_docs.yml b/.github/workflows/reusable_publish_docs.yml index 641b810b862..830a8fad37b 100644 --- a/.github/workflows/reusable_publish_docs.yml +++ b/.github/workflows/reusable_publish_docs.yml @@ -109,14 +109,18 @@ jobs: # Operations: # 1. Download the versions.json file from S3 # 2. Find any reference to the alias and delete it from the versions file - # 3. We insert the new version to the versions.json file with the corresponding alias + # 3. This is voodoo (don't use JQ): + # - we assign the input as $o and the new version/alias as $n, + # - we check if the version number exists in the file already (for republishing docs) + # - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input) + # - if it's a new version number, we add it at position 0 in the array. # 4. Once done, we'll upload it back to S3. run: | aws s3 cp \ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \ versions_old.json jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json - jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"]}]' < versions_proc.json > versions.json + jq '. as $o | [{"title": "${{ env.VERSION }}", "version": "${{ env.VERSION }}", "aliases": "${{env.ALIAS}}" }] as $n | $n | if .[0].title | test("[a-z]+") or any($o[].title == "${{ env.VERSION }}";.) then $o else $n + $o end' < versions_proc.json > versions.json aws s3 cp \ versions.json \ - s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json + s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json