Skip to content

Commit d4cd03d

Browse files
Copilotm-aciek
andauthored
improve directories layout: version subdirs and stable symlink (#18)
Agent-Logs-Url: https://github.com/m-aciek/python-docs-offline/sessions/2341d4a3-e39f-4303-8eca-661070f1b5cc Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
1 parent 3a2b247 commit d4cd03d

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

.github/workflows/build.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
runs-on: ubuntu-latest
4646
outputs:
4747
dist_version: ${{ steps.get-version.outputs.dist_version }}
48+
major_minor: ${{ steps.get-version.outputs.major_minor }}
4849
steps:
4950
- uses: actions/setup-python@master
5051
with:
@@ -54,7 +55,9 @@ jobs:
5455
repository: ${{ inputs.repository }}
5556
ref: ${{ inputs.reference }}
5657
- id: get-version
57-
run: echo "dist_version=$(python tools/extensions/patchlevel.py --short)" >> $GITHUB_OUTPUT
58+
run: |
59+
echo "dist_version=$(python tools/extensions/patchlevel.py --short)" >> $GITHUB_OUTPUT
60+
echo "major_minor=$(python -c 'from tools.extensions.patchlevel import get_version_info; print(get_version_info()[0])')" >> $GITHUB_OUTPUT
5861
working-directory: ./Doc
5962
build-html:
6063
needs: prepare
@@ -215,7 +218,7 @@ jobs:
215218

216219
- name: Prepare site directory
217220
run: |
218-
mkdir -p _site/3
221+
mkdir -p _site/${{ needs.prepare.outputs.major_minor }}
219222
# Remove git metadata; safe even if checkout above did not succeed
220223
rm -rf _site/.git
221224
@@ -227,11 +230,11 @@ jobs:
227230

228231
- name: Copy new archives into site directory
229232
run: |
230-
# Copy generated archives (zip, tar.bz2, epub) into _site/3/,
233+
# Copy generated archives (zip, tar.bz2, epub) into _site/<major_minor>/,
231234
# excluding PDF build logs which are for debugging only.
232235
find artifacts/ -type f \( -name "*.zip" -o -name "*.tar.bz2" -o -name "*.epub" \) \
233236
! -name "python-*-pdf-logs.zip" \
234-
-exec cp {} _site/3/ \;
237+
-exec cp {} _site/${{ needs.prepare.outputs.major_minor }}/ \;
235238
236239
- name: Upload Pages artifact
237240
uses: actions/upload-pages-artifact@v3

.github/workflows/schedule.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ jobs:
6868

6969
- name: Prepare site directory
7070
run: |
71-
mkdir -p _site/3
7271
# Remove git metadata; safe even if checkout above did not succeed
7372
rm -rf _site/.git
7473
@@ -80,11 +79,30 @@ jobs:
8079

8180
- name: Copy new archives into site directory
8281
run: |
83-
# Copy generated archives (zip, tar.bz2, epub) into _site/3/,
82+
# Copy generated archives (zip, tar.bz2, epub) into _site/<major_minor>/,
8483
# excluding PDF build logs which are for debugging only.
84+
# Extract major.minor from filenames like python-3.14.0-docs-html.zip.
8585
find artifacts/ -type f \( -name "*.zip" -o -name "*.tar.bz2" -o -name "*.epub" \) \
86-
! -name "python-*-pdf-logs.zip" \
87-
-exec cp {} _site/3/ \;
86+
! -name "python-*-pdf-logs.zip" | while read -r f; do
87+
filename=$(basename "$f")
88+
major_minor=$(echo "$filename" | sed -n 's/^python-\([0-9]*\.[0-9]*\).*/\1/p')
89+
mkdir -p "_site/$major_minor"
90+
cp "$f" "_site/$major_minor/"
91+
done
92+
93+
- name: Symlink 3 to stable version
94+
run: |
95+
# Create a relative symlink _site/3 -> <stable> (e.g. 3 -> 3.14),
96+
# pointing to the first "bugfix" (stable) version from release-cycle JSON.
97+
stable=$(curl -sf https://peps.python.org/api/release-cycle.json | \
98+
jq -r '[to_entries[] | select(.value.status == "bugfix")] | first | .key')
99+
if [ -z "$stable" ]; then
100+
echo "Error: no stable (bugfix) version found in release-cycle JSON" >&2
101+
exit 1
102+
fi
103+
# Remove existing 3 directory or symlink before creating new symlink
104+
rm -rf _site/3
105+
ln -s "$stable" _site/3
88106
89107
- name: Upload Pages artifact
90108
uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)