File
Blob: .github/workflows/release-python-snapshots.yml
| 1 | name: Make Python Snapshots |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | inputs: |
| 6 | update-released: |
| 7 | description: 'Update already released versions?' |
| 8 | required: false |
| 9 | default: false |
| 10 | type: boolean |
| 11 | |
| 12 | jobs: |
| 13 | build-linux: |
| 14 | uses: ./.github/workflows/_bazel.yml |
| 15 | with: |
| 16 | image: ubuntu-22.04 |
| 17 | os_name: linux |
| 18 | arch_name: 'X64' |
| 19 | suffix: '' |
| 20 | run_tests: false |
| 21 | extra_bazel_args: '--config=ci-linux --config=ci-test' |
| 22 | upload_binary: true |
| 23 | secrets: |
| 24 | BAZEL_CACHE_KEY: ${{ secrets.BAZEL_CACHE_KEY }} |
| 25 | WORKERS_MIRROR_URL: ${{ secrets.WORKERS_MIRROR_URL }} |
| 26 | GOOGLESOURCE_COOKIE: ${{ secrets.GOOGLESOURCE_COOKIE }} |
| 27 | |
| 28 | build: |
| 29 | needs: [build-linux] |
| 30 | runs-on: ubuntu-22.04 |
| 31 | name: Build and upload Python memory snapshots |
| 32 | steps: |
| 33 | - uses: actions/checkout@v6 |
| 34 | with: |
| 35 | show-progress: false |
| 36 | - uses: actions/setup-python@v6 |
| 37 | with: |
| 38 | python-version: '3.13' |
| 39 | - name: Setup Runner |
| 40 | uses: ./.github/actions/setup-runner |
| 41 | with: |
| 42 | GOOGLESOURCE_COOKIE: ${{ secrets.GOOGLESOURCE_COOKIE }} |
| 43 | - name: Download workerd binary |
| 44 | uses: actions/download-artifact@v8 |
| 45 | with: |
| 46 | name: linux-X64-binary |
| 47 | path: /tmp |
| 48 | |
| 49 | - name: Make workerd binary executable |
| 50 | run: chmod +x /tmp/workerd |
| 51 | |
| 52 | - name: Build and upload Python memory snapshots |
| 53 | env: |
| 54 | R2_ACCOUNT_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCOUNT_ID }} |
| 55 | R2_ACCESS_KEY_ID: ${{ secrets.PYODIDE_CAPNP_R2_ACCESS_KEY_ID }} |
| 56 | R2_SECRET_ACCESS_KEY: ${{ secrets.PYODIDE_CAPNP_R2_SECRET_ACCESS_KEY }} |
| 57 | WORKERD_BINARY: "/tmp/workerd" |
| 58 | run: | |
| 59 | bazel build @workerd//src/pyodide:bundle_version_info |
| 60 | # boto3 v1.36.0 fails with: |
| 61 | # NotImplemented error occurred in CreateMultipartUpload operation: Header 'x-amz-checksum-algorithm' with value 'CRC32' not implemented |
| 62 | pip install 'boto3<1.36.0' requests |
| 63 | python3 src/pyodide/make_snapshots.py ${{ inputs.update-released == true && '--update-released' || '' }} |
| 64 | |
| 65 | - name: Check for open PR and commit changes |
| 66 | env: |
| 67 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 68 | run: | |
| 69 | # Commit changes to python_metadata.bzl and push to branch |
| 70 | # Configure git |
| 71 | git config --local user.email "action@github.com" |
| 72 | git config --local user.name "release-python-snapshots.yml GitHub Action" |
| 73 | |
| 74 | # Get current branch name |
| 75 | BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) |
| 76 | echo "Current branch: $BRANCH_NAME" |
| 77 | |
| 78 | # Check if there are changes to python_metadata.bzl |
| 79 | if git diff --quiet build/python_metadata.bzl; then |
| 80 | echo "No changes to python_metadata.bzl" |
| 81 | exit 0 |
| 82 | fi |
| 83 | |
| 84 | echo "Changes detected in python_metadata.bzl" |
| 85 | |
| 86 | # Check if there's an open PR for this branch |
| 87 | PR_COUNT=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq length) |
| 88 | |
| 89 | if [ "$PR_COUNT" -eq 0 ]; then |
| 90 | echo "No open PR found for branch $BRANCH_NAME, skipping commit" |
| 91 | exit 0 |
| 92 | fi |
| 93 | |
| 94 | echo "Found open PR for branch $BRANCH_NAME" |
| 95 | |
| 96 | # Commit and push the changes |
| 97 | git add build/python_metadata.bzl |
| 98 | git commit --fixup HEAD -m "Update python_metadata.bzl with new snapshot info |
| 99 | |
| 100 | This commit updates the snapshot values in python_metadata.bzl based on the latest |
| 101 | snapshot uploads. |
| 102 | |
| 103 | 🤖 Generated automatically by release-python-snapshots workflow" |
| 104 | |
| 105 | # --no-verify because 'git merge-base origin/main HEAD' fails in pre-commit. |
| 106 | # There shouldn't be formatting errors anyways and if there are CI will catch it. |
| 107 | git push origin "$BRANCH_NAME" --no-verify |
| 108 | echo "Changes committed and pushed to $BRANCH_NAME" |