Use tblib to pickle errors in `run_in_pyodide`. 
name: prebuilt-docker-image
on:
  release:
    types: [published]
env:
  GHCR_REGISTRY: ghcr.io
  IMAGE_NAME: pyodide/pyodide
  PYODIDE_ENV_VERSION: 20220411-chrome99-firefox98
jobs:
  build_docker:
    runs-on: ubuntu-latest
    environment: Docker
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        id: builder
        with:
          driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
      - name: Log into Docker Hub registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}
      - name: Build and push Docker image to Docker Hub
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile-prebuilt
          push: true
          build-args: |
            VERSION=${{ env.PYODIDE_ENV_VERSION }}
          tags: ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
          labels: ${{ steps.meta.outputs.labels }}
          builder: ${{ steps.builder.outputs.name }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
  build_ghcr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        id: builder
        with:
          driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
      - name: Log into registry ${{ env.GHCR_REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.GHCR_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Build and push Docker image to ${{ env.GHCR_REGISTRY }}
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile-prebuilt
          push: true
          build-args: |
            VERSION=${{ env.PYODIDE_ENV_VERSION }}
          tags: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
          labels: ${{ steps.meta.outputs.labels }}
          builder: ${{ steps.builder.outputs.name }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}

name: prebuilt-docker-image
on:
  release:
    types: [published]
env:
  GHCR_REGISTRY: ghcr.io
  IMAGE_NAME: pyodide/pyodide
  PYODIDE_ENV_VERSION: 20220411-chrome99-firefox98
jobs:
  build_docker:
    runs-on: ubuntu-latest
    environment: Docker
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        id: builder
        with:
          driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
      - name: Log into Docker Hub registry
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.IMAGE_NAME }}
      - name: Build and push Docker image to Docker Hub
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile-prebuilt
          push: true
          build-args: |
            VERSION=${{ env.PYODIDE_ENV_VERSION }}
          tags: ${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
          labels: ${{ steps.meta.outputs.labels }}
          builder: ${{ steps.builder.outputs.name }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
  build_ghcr:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        id: builder
        with:
          driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
      - name: Log into registry ${{ env.GHCR_REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.GHCR_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Extract Docker metadata
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
      - name: Build and push Docker image to ${{ env.GHCR_REGISTRY }}
        id: build
        uses: docker/build-push-action@v2
        with:
          file: ./Dockerfile-prebuilt
          push: true
          build-args: |
            VERSION=${{ env.PYODIDE_ENV_VERSION }}
          tags: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }}
          labels: ${{ steps.meta.outputs.labels }}
          builder: ${{ steps.builder.outputs.name }}
      - name: Image digest
        run: echo ${{ steps.build.outputs.digest }}
