Build packages #64
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Advanced Micro Devices, Inc. | |
# | |
# Licensed under the Apache License v2.0 with LLVM Exceptions. | |
# See https://llvm.org/LICENSE.txt for license information. | |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
name: Build packages | |
on: | |
workflow_call: | |
inputs: | |
build_type: | |
description: The type of build version to produce ("stable", "rc", or "dev") | |
type: string | |
default: "rc" | |
workflow_dispatch: | |
inputs: | |
build_type: | |
description: The type of build version to produce ("stable", "rc", or "dev") | |
type: string | |
default: "rc" | |
schedule: | |
# Runs at 11:00 AM UTC, which is 3:00 AM PST (UTC-8) | |
- cron: '0 11 * * *' | |
permissions: | |
contents: read | |
jobs: | |
# Generate metadata on Linux and pass to later jobs. | |
setup_metadata: | |
if: ${{ github.repository_owner == 'nod-ai' || github.event_name != 'schedule' }} | |
runs-on: ubuntu-24.04 | |
outputs: | |
version_suffix: ${{ steps.version_rc.outputs.version_suffix }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Setup Python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 | |
with: | |
python-version: 3.12 | |
- name: Install Python packages | |
run: pip install packaging | |
# Compute version suffix based on inputs (default to 'rc') | |
- name: Compute stable version suffix | |
if: ${{ github.event.inputs.build_type == 'stable' }} | |
run: | |
version_suffix="" | |
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV | |
- name: Compute rc version suffix | |
if: ${{ github.event.inputs.build_type == 'rc' || github.event.inputs.build_type == '' }} | |
run: | |
version_suffix="$(printf 'rc%(%Y%m%d)T')" | |
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV | |
- name: Compute dev version suffix | |
if: ${{ github.event.inputs.build_type == 'dev' }} | |
run: | |
version_suffix=".dev0+${{ github.sha }}" | |
echo "version_suffix=${version_suffix}" >> $GITHUB_ENV | |
- name: Generate release candidate versions | |
id: version_rc | |
run: | | |
echo "version_suffix=${version_suffix}" >> $GITHUB_OUTPUT | |
python3 build_tools/python_deploy/compute_local_version.py --version-suffix=${version_suffix} sharktank | |
python3 build_tools/python_deploy/compute_local_version.py --version-suffix=${version_suffix} shortfin | |
python3 build_tools/python_deploy/compute_common_version.py -rc --version-suffix=${version_suffix} --write-json | |
- name: Upload version_local.json files | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: version_local_files | |
path: | | |
sharktank/version_local.json | |
shortfin/version_local.json | |
shark-ai/version_local.json | |
build_packages: | |
name: "${{ matrix.package }} :: ${{ matrix.platform }} :: ${{ matrix.python-version }}" | |
runs-on: ${{ matrix.runs-on }} | |
permissions: | |
contents: write | |
needs: [setup_metadata] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Ubuntu packages. | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shark-ai | |
python-version: cp311-cp311 # Ignored (generic wheel), set for workflow naming | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: sharktank | |
python-version: cp311-cp311 # Ignored (generic wheel), set for workflow naming | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shortfin | |
python-version: cp310-cp310 | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shortfin | |
python-version: cp311-cp311 | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shortfin | |
python-version: cp312-cp312 | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shortfin | |
python-version: cp313-cp313 | |
- runs-on: ubuntu-24.04 | |
platform: linux-x86_64 | |
package: shortfin | |
python-version: cp313-cp313t | |
# TODO(#130): macOS platform | |
# TODO(#130): Windows platform | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
path: "c" # Windows can hit path length limits, so use a short path. | |
submodules: false | |
- name: Download version_local.json files | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: version_local_files | |
path: ./c/ | |
merge-multiple: true | |
- name: Build shark-ai (Linux x86_64) | |
if: "matrix.package == 'shark-ai' && matrix.platform == 'linux-x86_64'" | |
env: | |
OUTPUT_DIR: "${{ github.workspace }}/bindist" | |
run: | | |
[ -e ./bindist/* ] && rm ./bindist/* | |
./c/build_tools/python_deploy/write_requirements.py --version-suffix=${{ needs.setup_metadata.outputs.version_suffix }} | |
./c/shark-ai/build_tools/build_linux_package.sh | |
- name: Build sharktank (Linux x86_64) | |
if: "matrix.package == 'sharktank' && matrix.platform == 'linux-x86_64'" | |
env: | |
OUTPUT_DIR: "${{ github.workspace }}/bindist" | |
run: | | |
[ -e ./bindist/* ] && rm ./bindist/* | |
./c/sharktank/build_tools/build_linux_package.sh | |
- name: Build shortfin (Linux x86_64, ${{ matrix.python-version }}) | |
if: "matrix.package == 'shortfin' && matrix.platform == 'linux-x86_64'" | |
env: | |
OUTPUT_DIR: "${{ github.workspace }}/bindist" | |
OVERRIDE_PYTHON_VERSIONS: "${{ matrix.python-version }}" | |
run: | | |
[ -e ./bindist/* ] && rm ./bindist/* | |
./c/shortfin/build_tools/build_linux_package.sh | |
- name: Upload python wheels | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
if-no-files-found: error | |
name: snapshot-${{ matrix.package }}-${{ matrix.platform }}-${{ matrix.python-version }} | |
path: bindist | |
- name: Release python wheels | |
if: ${{ github.event_name != 'workflow_call' }} | |
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 | |
with: | |
artifacts: bindist/*.whl | |
tag: "dev-wheels" | |
name: "dev-wheels" | |
body: "Automatic snapshot release of shark-ai python wheels." | |
removeArtifacts: false | |
allowUpdates: true | |
replacesArtifacts: true | |
makeLatest: false |