Skip to content

Commit e5d0b1c

Browse files
fix(docs): ensure versions.json is updated (#2505)
Co-authored-by: Leandro Damascena <[email protected]>
1 parent 460aaa0 commit e5d0b1c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/reusable_publish_docs.yml

+25
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,28 @@ jobs:
9999
aws s3 sync \
100100
site/ \
101101
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/${{ env.ALIAS }}/
102+
- name: Deploy Docs (Version JSON)
103+
env:
104+
VERSION: ${{ inputs.version }}
105+
ALIAS: ${{ inputs.alias }}
106+
# 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.
107+
# Instead, we're using some shell script that manages the versions.
108+
#
109+
# Operations:
110+
# 1. Download the versions.json file from S3
111+
# 2. Find any reference to the alias and delete it from the versions file
112+
# 3. This is voodoo (don't use JQ):
113+
# - we assign the input as $o and the new version/alias as $n,
114+
# - we check if the version number exists in the file already (for republishing docs)
115+
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
116+
# - if it's a new version number, we add it at position 0 in the array.
117+
# 4. Once done, we'll upload it back to S3.
118+
run: |
119+
aws s3 cp \
120+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json \
121+
versions_old.json
122+
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
123+
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
124+
aws s3 cp \
125+
versions.json \
126+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-python/versions.json

0 commit comments

Comments
 (0)