Skip to content

Commit 4ef8aad

Browse files
authored
Merge branch 'main' into feat/large_message
2 parents dfbe15e + 3dc8405 commit 4ef8aad

File tree

6 files changed

+186
-42
lines changed

6 files changed

+186
-42
lines changed

.github/workflows/build-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
- name: Build docs website
3535
run: |
3636
echo "GIT_PYTHON_REFRESH=quiet"
37-
make build-docs-website
37+
make build-docs-website

.github/workflows/docs.yml

-41
This file was deleted.
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Rebuild latest docs
2+
3+
# PROCESS
4+
#
5+
# 1. Build User Guide and API docs
6+
# 2. Publish to GitHub Pages
7+
# 3. Publish to S3 (new home)
8+
9+
# USAGE
10+
#
11+
# Only used for deploying a documentation hotfix to /latest and its associated version w/o a full release.
12+
#
13+
# Steps:
14+
#
15+
# 1. Trigger "Rebuild latest docs" workflow manually: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
16+
# 2. Use the latest version released under Releases e.g. 2.0.0
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
latest_published_version:
22+
description: "Latest published version to rebuild latest docs for, e.g. 1.4.2"
23+
default: "1.4.2"
24+
required: true
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
release-docs:
31+
permissions:
32+
contents: write # push to gh-pages
33+
pages: write # deploy gh-pages website
34+
id-token: write # trade JWT token for AWS credentials in AWS Docs account
35+
secrets: inherit
36+
uses: ./.github/workflows/reusable_publish_docs.yml
37+
with:
38+
version: ${{ inputs.latest_published_version }}
39+
alias: latest

.github/workflows/release-doc.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Docs
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
release-docs:
11+
permissions:
12+
contents: write
13+
pages: write
14+
id-token: write
15+
secrets: inherit
16+
uses: ./.github/workflows/reusable-publish-docs.yml
17+
with:
18+
version: main
19+
alias: stage
+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Reusable Publish docs
2+
3+
env:
4+
BRANCH: main
5+
ORIGIN: aws-powertools/powertools-lambda-java
6+
VERSION: ""
7+
8+
on:
9+
workflow_call:
10+
inputs:
11+
version:
12+
description: "Version to build and publish docs (1.28.0, develop)"
13+
required: true
14+
type: string
15+
alias:
16+
description: "Alias to associate version (latest, stage)"
17+
required: true
18+
type: string
19+
detached_mode:
20+
description: "Whether it's running in git detached mode to ensure git is sync'd"
21+
required: false
22+
default: false
23+
type: boolean
24+
25+
permissions:
26+
contents: write
27+
id-token: write
28+
pages: write
29+
30+
jobs:
31+
publish-docs:
32+
runs-on: ubuntu-latest
33+
environment: Docs
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
37+
with:
38+
# While `fetch-depth` is used to allow the workflow to later commit & push the changes.
39+
fetch-depth: 0
40+
- name: Setup dependencies
41+
uses: ./.github/actions/cached-node-modules
42+
- name: Set up Python
43+
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
44+
with:
45+
python-version: "3.8"
46+
- name: Install doc generation dependencies
47+
run: |
48+
pip install --upgrade pip
49+
pip install -r docs/requirements.txt
50+
- name: Setup doc deploy
51+
run: |
52+
git config --global user.name Docs deploy
53+
git config --global user.email [email protected]
54+
- name: Git refresh tip (detached mode)
55+
# Git Detached mode (release notes) doesn't have origin
56+
if: ${{ inputs.detached_mode }}
57+
run: |
58+
git config pull.rebase true
59+
git config remote.origin.url >&- || git remote add origin https://github.com/"$ORIGIN"
60+
git pull origin "$BRANCH"
61+
- name: Normalize Version Number
62+
run: echo "VERSION=$(echo ${{ inputs.version }} | sed 's/v//')" >> $GITHUB_ENV
63+
- name: Build docs website and API reference
64+
env:
65+
ALIAS: ${{ inputs.alias }}
66+
run: |
67+
rm -rf site
68+
mkdocs build
69+
mike deploy --update-aliases --no-redirect ${{ env.VERSION }} ${{ env.ALIAS }} --branch backup-gh-pages
70+
# Set latest version as a default
71+
mike set-default latest --branch backup-gh-pages
72+
- name: Configure AWS credentials
73+
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
74+
with:
75+
aws-region: us-east-1
76+
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
77+
- name: Copy API Docs
78+
run: |
79+
cp -r api site/
80+
81+
- name: Deploy Docs (Version)
82+
env:
83+
VERSION: ${{ inputs.version }}
84+
ALIAS: ${{ inputs.alias }}
85+
run: |
86+
aws s3 sync \
87+
site/ \
88+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.VERSION }}/
89+
- name: Deploy Docs (Alias)
90+
env:
91+
VERSION: ${{ inputs.version }}
92+
ALIAS: ${{ inputs.alias }}
93+
run: |
94+
aws s3 sync \
95+
site/ \
96+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.ALIAS }}/
97+
- name: Deploy Docs (Version JSON)
98+
env:
99+
VERSION: ${{ inputs.version }}
100+
ALIAS: ${{ inputs.alias }}
101+
102+
103+
# 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.
104+
# Instead, we're using some shell script that manages the versions.
105+
#
106+
# Operations:
107+
# 1. Download the versions.json file from S3
108+
# 2. Find any reference to the alias and delete it from the versions file
109+
# 3. This is voodoo (don't use JQ):
110+
# - we assign the input as $o and the new version/alias as $n,
111+
# - we check if the version number exists in the file already (for republishing docs)
112+
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
113+
# - if it's a new version number, we add it at position 0 in the array.
114+
# 4. Once done, we'll upload it back to S3.
115+
116+
run: |
117+
aws s3 cp \
118+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json \
119+
versions_old.json
120+
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
121+
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
122+
aws s3 cp \
123+
versions.json \
124+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json

mkdocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ extra_javascript:
8282
- javascript/extra.js
8383

8484
extra:
85+
version:
86+
provider: mike
87+
default: latest
8588
powertools:
8689
version: 1.16.1 # to update after each release (we do not want snapshot version here)
8790

0 commit comments

Comments
 (0)