Files
pytorch/.github/templates/upload.yml.j2
2025-09-05 22:46:36 +00:00

69 lines
2.3 KiB
Django/Jinja

{% import 'common.yml.j2' as common %}
{%- macro binary_env(config, is_windows=False) -%}
env:!{{ binary_env_as_input(config, is_windows, True) }}
{%- endmacro %}
{%- macro binary_env_as_input(config, is_windows=False, include_skip_tests=False) -%}
{%- if is_windows %}
PYTORCH_ROOT: ${{ github.workspace }}/pytorch
{%- else %}
PYTORCH_ROOT: /pytorch
{%- endif %}
PACKAGE_TYPE: !{{ config["package_type"] }}
# TODO: This is a legacy variable that we eventually want to get rid of in
# favor of GPU_ARCH_VERSION
DESIRED_CUDA: !{{ config["desired_cuda"] }}
{%- if config["gpu_arch_version"] %}
GPU_ARCH_VERSION: "!{{ config["gpu_arch_version"] }}"
{%- endif %}
GPU_ARCH_TYPE: !{{ config["gpu_arch_type"] }}
{%- if include_skip_tests %}
SKIP_ALL_TESTS: 1
{%- endif %}
{%- if not is_windows %}
DOCKER_IMAGE: !{{ config["container_image"] }}
DOCKER_IMAGE_TAG_PREFIX: !{{ config["container_image_tag_prefix"] }}
{%- endif %}
{%- if config["package_type"] == "libtorch" %}
{%- if config["libtorch_config"] %}
LIBTORCH_CONFIG: !{{ config["libtorch_config"] }}
{%- endif %}
LIBTORCH_VARIANT: !{{ config["libtorch_variant"] }}
{%- if is_windows %}
# This is a dummy value for libtorch to work correctly with our batch scripts
# without this value pip does not get installed for some reason
DESIRED_PYTHON: "3.10"
{%- endif %}
{%- else %}
DESIRED_PYTHON: "!{{ config["python_version"] }}"
{%- endif %}
{%- endmacro %}
{%- macro upload_binaries(config, is_windows=False, has_test=True, use_s3=True) -%}
!{{ config["build_name"] }}-upload: # Uploading
if: ${{ github.repository_owner == 'pytorch' }}
permissions:
id-token: write
contents: read
{%- if has_test %}
{%- if config["gpu_arch_type"] == "cuda-aarch64" %}
needs: !{{ config["build_name"] }}-build
{%- else %}
needs: !{{ config["build_name"] }}-test
{%- endif %}
{%- else %}
needs: !{{ config["build_name"] }}-build
{%- endif %}
with:!{{ binary_env_as_input(config, is_windows) }}
build_name: !{{ config["build_name"] }}
{%- if not use_s3 %}
use_s3: False
{%- endif %}
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/_binary-upload.yml
{%- endmacro %}