|
8 | 8 | permissions: |
9 | 9 | contents: write |
10 | 10 | jobs: |
11 | | - inform: |
12 | | - runs-on: ubuntu-latest |
13 | | - steps: |
14 | | - - name: Ensure input tag is latest patch for its major.minor |
15 | | - run: | |
16 | | - input_tag="${{ github.event.inputs.tag }}" |
17 | | - major_minor=$(echo "$input_tag" | grep -oE '^v[0-9]+\.[0-9]+') |
18 | | - latest_patch=$(git ls-remote --tags https://github.com/python/cpython.git | \ |
19 | | - awk '{print $2}' | grep -E "refs/tags/${major_minor}\\.([0-9]+([abrc][0-9]+)?)$" | \ |
20 | | - sed 's|refs/tags/||' | sed -E 's/([0-9]+)$/\1z0/' | sort -V | sed -E 's/z0$//' | tail -n1) |
21 | | - if [ "$input_tag" != "$latest_patch" ]; then |
22 | | - echo "Provided tag $input_tag is not the latest patch for $major_minor (latest: $latest_patch)." >&2 |
23 | | - exit 1 |
24 | | - fi |
25 | | - - uses: actions/setup-python@master |
26 | | - with: |
27 | | - python-version: 3 |
28 | | - - uses: actions/checkout@master |
29 | | - with: |
30 | | - repository: python/cpython |
31 | | - ref: ${{ github.event.inputs.tag }} |
32 | | - - run: make venv |
33 | | - working-directory: ./Doc |
34 | | - - run: | |
35 | | - echo "" >> conf.py |
36 | | - echo "notfound_context = {" >> conf.py |
37 | | - echo " 'title': 'Generating file'," >> conf.py |
38 | | - echo " 'body': '<h1>Generating file</h1>File is being <a href=\"https://github.com/m-aciek/python-docs-pdf/actions/runs/${{ github.run_id }}\">generated</a>. It should be available soon.'" >> conf.py |
39 | | - echo "}" >> conf.py |
40 | | - working-directory: ./Doc |
41 | | - - run: make html |
42 | | - working-directory: ./Doc |
43 | | - - run: | |
44 | | - sed -i 's|/en/latest/|https://docs.python.org/3/|g' ./build/html/404.html |
45 | | - working-directory: ./Doc |
46 | | - - uses: actions/upload-artifact@master |
47 | | - with: |
48 | | - path: ./Doc/build/html/404.html |
49 | | - - name: Checkout gh-pages branch |
50 | | - uses: actions/checkout@v4 |
51 | | - with: |
52 | | - ref: gh-pages |
53 | | - path: gh-pages |
54 | | - - name: Set major_minor variable |
55 | | - id: majorminor |
56 | | - run: | |
57 | | - input_tag="${{ github.event.inputs.tag }}" |
58 | | - major_minor=$(echo "$input_tag" | grep -oE '^[vV]([0-9]+\.[0-9]+)') |
59 | | - major_minor=${major_minor#v} |
60 | | - echo "major_minor=$major_minor" >> $GITHUB_OUTPUT |
61 | | - - name: Check and copy 404.html as zip/tar.bz2 if not exist |
62 | | - run: | |
63 | | - set -e |
64 | | - mkdir -p gh-pages/3 |
65 | | - for ext in zip tar.bz2; do |
66 | | - target="gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-pdf-a4.$ext" |
67 | | - if [ ! -f "$target" ]; then |
68 | | - cp ./Doc/build/html/404.html "$target" |
69 | | - fi |
70 | | - done |
71 | | - - name: Commit 404.html placeholders |
72 | | - run: | |
73 | | - cd gh-pages |
74 | | - git config user.name github-actions |
75 | | - git config user.email github-actions@github.com |
76 | | - git add 3/python-${{ steps.majorminor.outputs.major_minor }}-docs-pdf-a4.zip 3/python-${{ steps.majorminor.outputs.major_minor }}-docs-pdf-a4.tar.bz2 || true |
77 | | - git commit -m "Add 404.html placeholders for missing PDF archives for ${{ steps.majorminor.outputs.major_minor }}" || true |
78 | | - - name: Push commit |
79 | | - uses: ad-m/github-push-action@master |
80 | | - with: |
81 | | - branch: gh-pages |
82 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
83 | | - directory: gh-pages |
84 | 11 | build: |
85 | 12 | runs-on: ubuntu-latest |
86 | 13 | steps: |
|
0 commit comments