1- # Copyright 2025 Google LLC
1+ # Copyright 2023-2026 Google LLC
22
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
2828 build_mode :
2929 required : true
3030 type : string
31- dockerfile :
32- required : true
33- type : string
3431 maxtext_sha :
3532 required : true
3633 type : string
37- image_date :
38- required : false
39- type : string
4034 workflow :
4135 required : false
4236 type : string
4539 required : false
4640 type : string
4741 default : ' '
42+ include_test_assets :
43+ required : false
44+ type : boolean
45+ default : false
4846 secrets :
4947 HF_TOKEN :
5048 required : true
@@ -54,7 +52,7 @@ permissions:
5452
5553jobs :
5654 build_and_push :
57- runs-on : linux-x86-n2-16-buildkit
55+ runs-on : ubuntu-latest
5856 container : google/cloud-sdk:524.0.0
5957 if : >
6058 github.event_name == 'release' ||
8987 echo "workflow: ${{ inputs.workflow }}"
9088 echo "build_mode: ${{ inputs.build_mode }}"
9189 echo "image_name: ${{ inputs.image_name }}"
92- echo "dockerfile: ${{ inputs.dockerfile }}"
93-
94- - name : Checkout MaxText
95- uses : actions/checkout@v5
96- if : steps.check.outputs.should_run == 'true'
97- with :
98- # This ensures that every job clones the exact same commit as "setup" job
99- ref : ${{ inputs.maxtext_sha }}
100-
101- - name : Mark git repositories as safe
102- run : git config --global --add safe.directory ${GITHUB_WORKSPACE}
103- if : steps.check.outputs.should_run == 'true'
10490
10591 - name : Configure Docker
10692 run : gcloud auth configure-docker us-docker.pkg.dev,gcr.io -q
@@ -113,24 +99,51 @@ jobs:
11399 driver : remote
114100 endpoint : tcp://localhost:1234
115101
116- - name : Build and push Docker image
117- uses : docker/build-push-action@v6
102+ - name : Download MaxText wheel
103+ uses : actions/download-artifact@v4
118104 if : steps.check.outputs.should_run == 'true'
119105 with :
120- push : true
121- context : .
122- file : ${{ inputs.dockerfile }}
123- tags : gcr.io/tpu-prod-env-multipod/${{ inputs.image_name }}:${{ github.run_id }}
124- cache-from : type=gha
125- outputs : type=image,compression=zstd,force-compression=true
126- build-args : |
127- DEVICE=${{ inputs.device }}
128- MODE=${{ inputs.build_mode }}
106+ name : maxtext-wheel
107+
108+ - name : Install uv and set the Python version
109+ uses : astral-sh/setup-uv@v7
110+ if : steps.check.outputs.should_run == 'true'
111+ with :
112+ python-version : ' 3.12'
113+ enable-cache : true
114+
115+ - name : Install MaxText wheel
116+ if : steps.check.outputs.should_run == 'true'
117+ shell : bash
118+ run : |
119+ uv venv --seed
120+ source .venv/bin/activate
121+ maxtext_wheel=$(ls maxtext-*-py3-none-any.whl 2>/dev/null)
122+ uv pip install ${maxtext_wheel}[runner] --resolution=lowest
123+
124+ - name : Build and push Docker image
125+ if : steps.check.outputs.should_run == 'true'
126+ shell : bash
127+ env :
128+ IMAGE_TAG : " gcr.io/tpu-prod-env-multipod/${{ inputs.image_name }}:${{ github.run_id }}"
129+ INCLUDE_TEST_ASSETS : ${{ inputs.include_test_assets }}
130+ PROJECT : tpu-prod-env-multipod
131+ run : |
132+ source .venv/bin/activate
133+ echo "Building MaxText Docker image..."
134+ #apt-get update && apt-get install -y sudo
135+ #sudo .venv/bin/python3 -m dependencies.scripts.build_maxtext_docker_image \
136+ build_maxtext_docker_image \
137+ DEVICE=${{ inputs.device }} \
138+ MODE=${{ inputs.build_mode }} \
129139 WORKFLOW=${{ inputs.workflow }}
130- PACKAGE_DIR=./src
131- JAX_VERSION=NONE
132- LIBTPU_VERSION=NONE
133- INCLUDE_TEST_ASSETS=true
140+
141+ echo "Pushing MaxText Docker image..."
142+ #sudo .venv/bin/python3 -m dependencies.scripts.upload_maxtext_docker_image \
143+ upload_maxtext_docker_image \
144+ CLOUD_IMAGE_NAME=${{ inputs.image_name }}
145+ docker push "${IMAGE_TAG}"
146+ echo "Successfully pushed ${IMAGE_TAG}"
134147
135148 - name : Add tags to Docker image
136149 if : steps.check.outputs.should_run == 'true'
@@ -146,16 +159,16 @@ jobs:
146159 echo "Tagging docker images corresponding to nightly release..."
147160
148161 # Add date tag
149- gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
162+ IMAGE_DATE="$(date +%Y-%m-%d)"
163+ gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:$IMAGE_DATE" --quiet
150164
151165 # Convert date to YYYYMMDD format
152- clean_date=$(echo "${INPUTS_IMAGE_DATE} " | sed 's/[-:]//g' | cut -c1-8)
166+ clean_date=$(echo "$IMAGE_DATE " | sed 's/[-:]//g' | cut -c1-8)
153167
154168 # Add MaxText tag
155169 gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:maxtext_${MAXTEXT_SHA}_${clean_date}" --quiet
156170 fi
157171 env :
158172 INPUTS_IMAGE_NAME : ${{ inputs.image_name }}
159- INPUTS_IMAGE_DATE : ${{ inputs.image_date }}
160173 INPUTS_VERSION_NAME : ${{ inputs.version_name }}
161174 MAXTEXT_SHA : ${{ inputs.maxtext_sha }}
0 commit comments