Skip to content
File

Blob: .github/workflows/release-python-runtime.yml

yaml90 lines
1name: Build Python Runtime
2 
3on:
4 workflow_dispatch:
5 inputs:
6 update-released:
7 description: 'Update already released versions?'
8 required: false
9 default: false
10 type: boolean
11 
12jobs:
13 build:
14 runs-on: ubuntu-22.04
15 name: build Python runtime
16 steps:
17 - uses: actions/checkout@v6
18 with:
19 show-progress: false
20 - uses: actions/setup-python@v6
21 with:
22 python-version: '3.13'
23 - name: Setup Runner
24 uses: ./.github/actions/setup-runner
25 with:
26 GOOGLESOURCE_COOKIE: ${{ secrets.GOOGLESOURCE_COOKIE }}
27 - name: Configure download mirrors
28 shell: bash
29 run: |
30 if [ ! -z "${{ secrets.WORKERS_MIRROR_URL }}" ] ; then
31 # Strip comment in front of WORKERS_MIRROR_URL, then substitute secret to use it.
32 sed -e '/WORKERS_MIRROR_URL/ { s@# *@@; s@WORKERS_MIRROR_URL@${{ secrets.WORKERS_MIRROR_URL }}@; }' -i.bak build/deps/nodejs.MODULE.bazel
33 fi
34 - name: Build and upload Pyodide capnproto bundle
35 env:
36 R2_ACCOUNT_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCOUNT_ID }}
37 R2_ACCESS_KEY_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCESS_KEY_ID }}
38 R2_SECRET_ACCESS_KEY: ${{ secrets.PYODIDE_CAPNP_R2_SECRET_ACCESS_KEY }}
39 run: |
40 bazel build @workerd//src/pyodide:python_bundles @workerd//src/pyodide:bundle_version_info --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev
41 # boto3 v1.36.0 fails with:
42 # NotImplemented error occurred in CreateMultipartUpload operation: Header 'x-amz-checksum-algorithm' with value 'CRC32' not implemented
43 pip install 'boto3<1.36.0' requests
44 python3 src/pyodide/upload_bundles.py ${{ inputs.update-released == true && '--update-released' || '' }}
45
46 - name: Check for open PR and commit changes
47 env:
48 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 run: |
50 # Commit changes to python_metadata.bzl and push to branch
51 # Configure git
52 git config --local user.email "action@github.com"
53 git config --local user.name "release-python-runtime.yml GitHub Action"
54
55 # Get current branch name
56 BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
57 echo "Current branch: $BRANCH_NAME"
58 
59 # Check if there are changes to python_metadata.bzl
60 if git diff --quiet build/python_metadata.bzl; then
61 echo "No changes to python_metadata.bzl"
62 exit 0
63 fi
64 
65 echo "Changes detected in python_metadata.bzl"
66 
67 # Check if there's an open PR for this branch
68 PR_COUNT=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq length)
69 
70 if [ "$PR_COUNT" -eq 0 ]; then
71 echo "No open PR found for branch $BRANCH_NAME, skipping commit"
72 exit 0
73 fi
74 
75 echo "Found open PR for branch $BRANCH_NAME"
76 
77 # Commit and push the changes
78 git add build/python_metadata.bzl build/deps/python.MODULE.bazel
79 git commit --fixup HEAD -m "Update python_metadata.bzl with new bundle info
80
81 This commit updates the backport and integrity values in python_metadata.bzl
82 based on the latest Pyodide bundle upload.
83
84 🤖 Generated automatically by release-python-runtime workflow"
85 
86 # --no-verify because 'git merge-base origin/main HEAD' fails in pre-commit.
87 # There shouldn't be formatting errors anyways and if there are CI will catch it.
88 git push origin "$BRANCH_NAME" --no-verify
89 echo "Changes committed and pushed to $BRANCH_NAME"