build 3.13 #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| run-name: build ${{ github.event.inputs.tag }} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag from CPython repository' | |
| required: true | |
| default: 'v3.14.0' | |
| skip-tag-check: | |
| description: 'Allow running build for non-latest patch tags (useful for testing)' | |
| required: true | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Ensure input tag is latest patch for its major.minor | |
| run: | | |
| input_tag="${{ github.event.inputs.tag }}" | |
| major_minor=$(echo "$input_tag" | grep -oE '^v[0-9]+\.[0-9]+') | |
| latest_patch=$(git ls-remote --tags https://github.com/python/cpython.git | \ | |
| awk '{print $2}' | grep -E "refs/tags/${major_minor}\\.([0-9]+([abrc][0-9]+)?)$" | \ | |
| sed 's|refs/tags/||' | sed -E 's/([0-9]+)$/\1z0/' | sort -V | sed -E 's/z0$//' | tail -n1) | |
| if [ "$input_tag" != "$latest_patch" ]; then | |
| echo "Provided tag $input_tag is not the latest patch for $major_minor (latest: $latest_patch)." >&2 | |
| exit 1 | |
| fi | |
| if: ${{ github.event.inputs.skip-tag-check == false }} | |
| - uses: actions/setup-python@master | |
| with: | |
| python-version: 3 | |
| - uses: actions/checkout@master | |
| with: | |
| repository: python/cpython | |
| ref: ${{ github.event.inputs.tag }} | |
| - run: make venv | |
| working-directory: ./Doc | |
| - run: sudo apt-get update | |
| - run: sudo apt-get install -y latexmk texlive-xetex fonts-freefont-otf xindy texinfo | |
| - run: make dist-html | |
| id: build-html | |
| working-directory: ./Doc | |
| continue-on-error: true | |
| - run: make dist-text | |
| id: build-text | |
| working-directory: ./Doc | |
| continue-on-error: true | |
| - run: make dist-texinfo | |
| id: build-texinfo | |
| working-directory: ./Doc | |
| continue-on-error: true | |
| - run: make dist-epub | |
| id: build-epub | |
| working-directory: ./Doc | |
| continue-on-error: true | |
| - run: make dist-pdf | |
| id: build-pdf | |
| working-directory: ./Doc | |
| continue-on-error: true | |
| - name: Strip leading v from tag | |
| id: tag-no-v | |
| run: | | |
| echo "tag_no_v=${GITHUB_EVENT_INPUTS_TAG#v}" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_EVENT_INPUTS_TAG: ${{ github.event.inputs.tag }} | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-pdf-a4.zip | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-pdf-a4.zip | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-pdf-a4.tar.bz2 | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-pdf-a4.tar.bz2 | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-html.zip | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-html.zip | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-html.tar.bz2 | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-html.tar.bz2 | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-text.zip | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-text.zip | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-text.tar.bz2 | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-text.tar.bz2 | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-texinfo.zip | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-texinfo.zip | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs-texinfo.tar.bz2 | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-texinfo.tar.bz2 | |
| if-no-files-found: ignore | |
| - uses: actions/upload-artifact@master | |
| with: | |
| name: ${{ github.event.inputs.tag }}-docs.epub | |
| path: ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs.epub | |
| if-no-files-found: ignore | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages | |
| - name: Set major_minor variable | |
| id: majorminor | |
| run: | | |
| input_tag="${{ github.event.inputs.tag }}" | |
| major_minor=$(echo "$input_tag" | grep -oE '^[vV]([0-9]+\.[0-9]+)') | |
| major_minor=${major_minor#v} | |
| echo "major_minor=$major_minor" >> $GITHUB_OUTPUT | |
| - name: Copy generated archives to gh-pages | |
| run: | | |
| mkdir -p gh-pages/3 | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-pdf-a4.zip gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-pdf-a4.zip 2>/dev/null || true | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-pdf-a4.tar.bz2 gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-pdf-a4.tar.bz2 2>/dev/null || true | |
| # HTML | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-html.zip gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-html.zip 2>/dev/null || true | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-html.tar.bz2 gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-html.tar.bz2 2>/dev/null || true | |
| # Text | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-text.zip gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-text.zip 2>/dev/null || true | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-text.tar.bz2 gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-text.tar.bz2 2>/dev/null || true | |
| # Texinfo | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-texinfo.zip gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-texinfo.zip 2>/dev/null || true | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs-texinfo.tar.bz2 gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs-texinfo.tar.bz2 2>/dev/null || true | |
| # EPUB | |
| cp ./Doc/dist/python-${{ steps.tag-no-v.outputs.tag_no_v }}-docs.epub gh-pages/3/python-${{ steps.majorminor.outputs.major_minor }}-docs.epub 2>/dev/null || true | |
| - name: Commit generated archives | |
| id: commit | |
| run: | | |
| cd gh-pages | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git add 3/python-${{ steps.majorminor.outputs.major_minor }}-docs-* || true | |
| if git diff --cached --quiet; then | |
| echo "No documentation archives to commit" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "Update documentation archives for ${{ steps.majorminor.outputs.major_minor }}" | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Push commit | |
| if: steps.commit.outputs.has_changes == 'true' | |
| uses: ad-m/github-push-action@master | |
| with: | |
| branch: gh-pages | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| directory: gh-pages | |
| - name: Check for build failures | |
| if: always() | |
| run: | | |
| failed_formats=() | |
| if [ "${{ steps.build-html.outcome }}" == "failure" ]; then | |
| failed_formats+=("HTML") | |
| fi | |
| if [ "${{ steps.build-text.outcome }}" == "failure" ]; then | |
| failed_formats+=("Text") | |
| fi | |
| if [ "${{ steps.build-texinfo.outcome }}" == "failure" ]; then | |
| failed_formats+=("Texinfo") | |
| fi | |
| if [ "${{ steps.build-epub.outcome }}" == "failure" ]; then | |
| failed_formats+=("EPUB") | |
| fi | |
| if [ "${{ steps.build-pdf.outcome }}" == "failure" ]; then | |
| failed_formats+=("PDF") | |
| fi | |
| if [ ${#failed_formats[@]} -gt 0 ]; then | |
| echo "The following format(s) failed to build: ${failed_formats[*]}" | |
| exit 1 | |
| else | |
| echo "All formats built successfully" | |
| fi |